:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(flags): surface the real blast-radius error and hide futile retries (#79495)
posthog[bot]df79577a3638
diff --git a/frontend/src/lib/api-error.ts b/frontend/src/lib/api-error.tsindex ea3d0efe7684..aa75b33f3483 100644--- a/frontend/src/lib/api-error.ts+++ b/frontend/src/lib/api-error.ts@@ -6,6 +6,9 @@ export function isAccessDeniedError(error: { status?: number; code?: string | nureturn error.status === 403 && error.code === 'permission_denied'}+/** DRF code for `ClickHouseQueryMemoryLimitExceeded` (posthog/exceptions.py). Keep in sync with the backend. */+export const CLICKHOUSE_MEMORY_LIMIT_ERROR_CODE = 'clickhouse_memory_limit_exceeded'+/*** A 409 from the approvals gate: the change was policy-gated and a change request was created,* or one is already pending. Approval 409 bodies always carry `change_request_id`diff --git a/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.test.tsx b/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.test.tsxnew file mode 100644index 000000000000..48992e9602b5--- /dev/null+++ b/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.test.tsx@@ -0,0 +1,12 @@+import { render } from '@testing-library/react'++import { BlastRadiusErrorMessage } from './BlastRadiusErrorMessage'++// Link-rendering coverage lives in scenes/insights/EmptyStates/InsightEmptyState.test.tsx, which+// tests the shared renderDetailWithLinks this delegates to.+describe('BlastRadiusErrorMessage', () => {+ it('falls back to a generic line without a detail', () => {+ const { container } = render(<BlastRadiusErrorMessage error={{ status: 500 }} pluralName="organizations" />)+ expect(container.textContent).toBe("Couldn't estimate how many organizations match.")+ })+})diff --git a/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.tsx b/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.tsxnew file mode 100644index 000000000000..d80866152c60--- /dev/null+++ b/frontend/src/scenes/feature-flags/BlastRadiusErrorMessage.tsx@@ -0,0 +1,17 @@+import { renderDetailWithLinks } from 'lib/utils/renderDetailWithLinks'++import { BlastRadiusError, getBlastRadiusErrorMessage } from './featureFlagReleaseConditionsLogic'++export function BlastRadiusErrorMessage({+ error,+ pluralName,+}: {+ error: BlastRadiusError+ pluralName: string+}): JSX.Element {+ return (+ <span className="min-w-0 break-words">+ {renderDetailWithLinks(getBlastRadiusErrorMessage(error, pluralName))}+ </span>+ )+}diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.blastRadiusError.test.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.blastRadiusError.test.tsxnew file mode 100644index 000000000000..6a8df034016e--- /dev/null+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.blastRadiusError.test.tsx@@ -0,0 +1,96 @@+import '@testing-library/jest-dom'++import { cleanup, render, waitFor } from '@testing-library/react'+import { Provider } from 'kea'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'+import { FeatureFlagGroupType, FeatureFlagType, PropertyFilterType, PropertyOperator } from '~/types'++import { FeatureFlagReleaseConditions } from './FeatureFlagReleaseConditions'+import { FeatureFlagReleaseConditionsCollapsible } from './FeatureFlagReleaseConditionsCollapsible'++jest.mock('lib/components/AutoSizer', () => ({+ AutoSizer: ({ renderProp }: { renderProp: (size: { height: number; width: number }) => React.ReactNode }) =>+ renderProp({ height: 400, width: 400 }),+}))++function buildFilters(): FeatureFlagType['filters'] {+ const group: FeatureFlagGroupType = {+ properties: [+ {+ key: 'aloha',+ value: 'aloha',+ type: PropertyFilterType.Person,+ operator: PropertyOperator.Exact,+ },+ ],+ rollout_percentage: 100,+ variant: null,+ sort_key: 'group-1',+ }+ return { groups: [group], multivariate: null, payloads: {} }+}++describe('feature flag release conditions blast radius error', () => {+ beforeEach(() => {+ initKeaTests()+ useMocks({+ get: {+ '/api/projects/:team/event_definitions': { results: [] },+ '/api/projects/:team/property_definitions': { results: [] },+ // featureFlagLogic mounts alongside and loads the flag; the unhandled-request+ // floor has no `filters`, which crashes payload conversion+ '/api/projects/:team/feature_flags/1234/': {+ id: 1234,+ key: 'test-flag',+ filters: { groups: [], multivariate: null, payloads: {} },+ },+ '/api/projects/:team/actions': { results: [] },+ },+ post: {+ '/api/environments/:team/query': { results: [] },+ // A deterministic 400 must not offer a Retry that would just fail again.+ '/api/projects/:team/feature_flags/user_blast_radius': () => [+ 400,+ { detail: 'These filters are invalid.' },+ ],+ },+ })+ })++ afterEach(() => {+ cleanup()+ })++ it('hides Retry and shows the backend detail in FeatureFlagReleaseConditions', async () => {+ render(+ <Provider>+ <FeatureFlagReleaseConditions id="1234" filters={buildFilters()} onChange={jest.fn()} />+ </Provider>+ )++ await waitFor(() => {+ expect(document.body).toHaveTextContent('These filters are invalid.')+ })+ expect(document.body).not.toHaveTextContent('Retry')+ })++ it('hides Retry and shows the backend detail in FeatureFlagReleaseConditionsCollapsible', async () => {+ render(+ <Provider>+ <FeatureFlagReleaseConditionsCollapsible+ id="1234"+ flagId={1234}+ filters={buildFilters()}+ onChange={jest.fn()}+ />+ </Provider>+ )++ await waitFor(() => {+ expect(document.body).toHaveTextContent('These filters are invalid.')+ })+ expect(document.body).not.toHaveTextContent('Retry')+ })+})diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsxindex 7d812d56689a..5d80c82471de 100644--- a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx@@ -47,11 +47,13 @@ import {import { FractionalRolloutWarning } from 'products/feature_flags/frontend/FractionalRolloutWarning'import { resolveAggregationGroupTypeIndex } from './aggregation'+import { BlastRadiusErrorMessage } from './BlastRadiusErrorMessage'import { EARLY_ACCESS_GROUP_TARGETING_DISABLED_REASON, MATCHING_ESTIMATE_TOOLTIP } from './constants'import { featureFlagLogic } from './featureFlagLogic'import {FeatureFlagReleaseConditionsLogicProps,featureFlagReleaseConditionsLogic,+ isBlastRadiusErrorRetryable,isDistinctIdFilter,withResolvedFlagLabels,} from './featureFlagReleaseConditionsLogic'@@ -460,27 +462,33 @@ export function FeatureFlagReleaseConditions({const sortKey = group.sort_keyconst affected = sortKey ? affectedCounts[sortKey] : undefinedconst total = sortKey ? totalCounts[sortKey] : undefined- if (sortKey && blastRadiusErrors[sortKey]) {+ const blastRadiusError = sortKey ? blastRadiusErrors[sortKey] : undefined+ if (sortKey && blastRadiusError) {return (<divrole="status"- className="basis-full flex items-center gap-2 mt-1 text-secondary"+ className="basis-full flex items-start gap-2 mt-1 text-secondary">- <IconErrorOutline className="text-danger text-base shrink-0" />- <span>Couldn't estimate how many {pluralName} match.</span>- <LemonButton- type="secondary"- size="xsmall"- onClick={() =>- calculateBlastRadiusForCondition(- sortKey,- group.properties,- resolvedGroupTypeIndex- )- }- >- Retry- </LemonButton>+ <IconErrorOutline className="text-danger text-base shrink-0 mt-0.5" />+ <BlastRadiusErrorMessage+ error={blastRadiusError}+ pluralName={pluralName}+ />+ {isBlastRadiusErrorRetryable(blastRadiusError) && (+ <LemonButton+ type="secondary"+ size="xsmall"+ onClick={() =>+ calculateBlastRadiusForCondition(+ sortKey,+ group.properties,+ resolvedGroupTypeIndex+ )+ }+ >+ Retry+ </LemonButton>+ )}</div>)}diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsxindex a86f72ee9b85..b431bfb02653 100644--- a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx@@ -74,6 +74,7 @@ import { INTENT_METADATA } from 'products/feature_flags/frontend/featureFlagTempimport { FractionalRolloutWarning } from 'products/feature_flags/frontend/FractionalRolloutWarning'import { resolveAggregationGroupTypeIndex } from './aggregation'+import { BlastRadiusErrorMessage } from './BlastRadiusErrorMessage'import { EARLY_ACCESS_GROUP_TARGETING_DISABLED_REASON, MATCHING_ESTIMATE_TOOLTIP } from './constants'import { EarlyExitIndicator } from './EarlyExitIndicator'import { FeatureFlagConditionDragHandle } from './FeatureFlagConditionDragHandle'@@ -81,9 +82,11 @@ import { FeatureFlagConditionWarning } from './FeatureFlagConditionWarning'import { FlagIntent, featureFlagIntentWarningLogic } from './featureFlagIntentWarningLogic'import { FeatureFlagLogicProps } from './featureFlagLogic'import {+ BlastRadiusError,FeatureFlagReleaseConditionsLogicProps,FeatureFlagGroupTypeWithSortKey,featureFlagReleaseConditionsLogic,+ isBlastRadiusErrorRetryable,isDistinctIdFilter,withResolvedFlagLabels,} from './featureFlagReleaseConditionsLogic'@@ -344,7 +347,7 @@ interface ConditionProps {totalGroups: numberaffectedCounts: Record<string, number | undefined>totalCounts: Record<string, number | undefined>- blastRadiusErrors: Record<string, boolean>+ blastRadiusErrors: Record<string, BlastRadiusError | undefined>calculateBlastRadiusForCondition: (sortKey: string,properties: AnyPropertyFilter[] | undefined,@@ -512,6 +515,7 @@ const ConditionContent = ({releaseFilters.aggregation_group_type_index)const resolvedSingularTargetName = aggregationLabel(resolvedGroupTypeIndex, true).singular+ const blastRadiusError = group.sort_key ? blastRadiusErrors[group.sort_key] : undefinedreturn (<div@@ -686,27 +690,32 @@ const ConditionContent = ({data-attr="rollout-percentage"/></div>- {group.sort_key && blastRadiusErrors[group.sort_key] ? (+ {blastRadiusError ? (<divrole="status"- className="text-xs text-muted mt-2 flex items-center gap-2"+ className="text-xs text-muted mt-2 flex items-start gap-2">- <IconErrorOutline className="text-danger text-sm shrink-0" />- <span>Couldn't estimate how many {resolvedTargetName} match.</span>- <LemonButton- type="secondary"- size="xsmall"- onClick={() =>- group.sort_key &&- calculateBlastRadiusForCondition(- group.sort_key,- group.properties,- resolvedGroupTypeIndex- )- }- >- Retry- </LemonButton>+ <IconErrorOutline className="text-danger text-sm shrink-0 mt-0.5" />+ <BlastRadiusErrorMessage+ error={blastRadiusError}+ pluralName={resolvedTargetName}+ />+ {isBlastRadiusErrorRetryable(blastRadiusError) && (+ <LemonButton+ type="secondary"+ size="xsmall"+ onClick={() =>+ group.sort_key &&+ calculateBlastRadiusForCondition(+ group.sort_key,+ group.properties,+ resolvedGroupTypeIndex+ )+ }+ >+ Retry+ </LemonButton>+ )}</div>) : group.sort_key && affectedCounts[group.sort_key] !== undefined ? (<div className="text-xs text-muted mt-2">diff --git a/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.test.tsindex 4cc7c056c9e1..9817d49bafb8 100644--- a/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.test.ts+++ b/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.test.ts@@ -17,7 +17,12 @@ import {} from '~/types'import { resolveAggregationGroupTypeIndex } from './aggregation'-import { featureFlagReleaseConditionsLogic, withResolvedFlagLabels } from './featureFlagReleaseConditionsLogic'+import {+ featureFlagReleaseConditionsLogic,+ getBlastRadiusErrorMessage,+ isBlastRadiusErrorRetryable,+ withResolvedFlagLabels,+} from './featureFlagReleaseConditionsLogic'jest.mock('uuid', () => ({v4: jest.fn(),@@ -99,38 +104,50 @@ describe('the feature flag release conditions logic', () => {})})- it('flags a distinct error state when the blast radius call fails', async () => {- const createSpy = jest.spyOn(api, 'create').mockRejectedValue(new Error('boom'))-- try {- await expectLogic(logic, () => {- logic.actions.calculateBlastRadiusForCondition(- 'X',- [- {- key: 'aloha',- value: 'aloha',- type: PropertyFilterType.Person,- operator: PropertyOperator.Exact,- },- ],- null- )- }).toFinishAllListeners()+ it('captures the API error so the UI can explain the failure', async () => {+ // Routed through a mocked HTTP response, not a hand-built ApiError, to exercise the+ // real ApiError.fromResponse mapping.+ useMocks({+ post: {+ '/api/projects/:team/feature_flags/user_blast_radius': () => [+ 513,+ {+ code: 'clickhouse_memory_limit_exceeded',+ detail: 'This query ran out of memory before it could finish.',+ },+ ],+ },+ })- // The error is surfaced distinctly rather than masked as -1, which the render- // path can't tell apart from the still-loading (undefined) state.- expect(logic.values.blastRadiusErrors.X).toBe(true)- expect(logic.values.affectedCounts.X).toBeUndefined()- expect(logic.values.totalCounts.X).toBeUndefined()- } finally {- createSpy.mockRestore()- }+ await expectLogic(logic, () => {+ logic.actions.calculateBlastRadiusForCondition(+ 'X',+ [+ {+ key: 'aloha',+ value: 'aloha',+ type: PropertyFilterType.Person,+ operator: PropertyOperator.Exact,+ },+ ],+ null+ )+ }).toFinishAllListeners()++ // The caught error is kept (status/code/detail), not masked as -1, which the render+ // path can't tell apart from the still-loading (undefined) state.+ expect(logic.values.blastRadiusErrors.X).toEqual({+ status: 513,+ code: 'clickhouse_memory_limit_exceeded',+ detail: 'This query ran out of memory before it could finish.',+ })+ expect(logic.values.affectedCounts.X).toBeUndefined()+ expect(logic.values.totalCounts.X).toBeUndefined()})it('clears the error state once a recalculation succeeds', async () => {- logic.actions.setBlastRadiusError('X')- expect(logic.values.blastRadiusErrors.X).toBe(true)+ logic.actions.setBlastRadiusError('X', { status: 500 })+ expect(logic.values.blastRadiusErrors.X).toEqual({ status: 500 })const createSpy = jest.spyOn(api, 'create').mockResolvedValue({ affected: 10, total: 100 })try {@@ -157,6 +174,47 @@ describe('the feature flag release conditions logic', () => {}})+ // These guard the core of the fix: a deterministic failure must not offer a retry that+ // can't help, and the backend's own copy must be shown when it's actionable.+ it.each([+ ['a transient timeout is retryable', { status: 504 }, true],+ ['a server fault is retryable', { status: 500 }, true],+ ['a rate-limited request is retryable', { status: 429 }, true],+ ['a bad request is not retryable', { status: 400 }, false],+ ['an unauthorized request is not retryable', { status: 401 }, false],+ ['a too-slow estimate is not retryable', { status: 512 }, false],+ [+ 'a per-query memory limit is not retryable',+ { status: 513, code: 'clickhouse_memory_limit_exceeded' },+ false,+ ],+ ])('%s', (_name, error, retryable) => {+ expect(isBlastRadiusErrorRetryable(error)).toBe(retryable)+ })++ const generic = "Couldn't estimate how many users match."+ it.each([+ [+ 'shows the backend detail for a bad request',+ { status: 400, detail: 'These filters are invalid.' },+ 'These filters are invalid.',+ ],+ [+ 'shows the backend detail for a too-slow estimate',+ { status: 512, detail: 'Estimated query execution time is too long.' },+ 'Estimated query execution time is too long.',+ ],+ [+ 'shows the backend detail for a memory limit',+ { status: 513, code: 'clickhouse_memory_limit_exceeded', detail: 'Ran out of memory.' },+ 'Ran out of memory.',+ ],+ ['falls back to a generic line for a timeout', { status: 504, detail: 'Gateway timeout.' }, generic],+ ['falls back to a generic line when there is no detail', { status: 500 }, generic],+ ])('%s', (_name, error, expected) => {+ expect(getBlastRadiusErrorMessage(error, 'users')).toBe(expected)+ })+it('loads when editing a flag with multiple conditions', async () => {// clear existing logiclogic?.unmount()diff --git a/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.ts b/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.tsindex e98e7982a5ef..1c04bbd439a3 100644--- a/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.ts+++ b/frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.ts@@ -17,6 +17,7 @@ import { subscriptions } from 'kea-subscriptions'import { v4 as uuidv4 } from 'uuid'import api from 'lib/api'+import { ApiError, CLICKHOUSE_MEMORY_LIMIT_ERROR_CODE } from 'lib/api-error'import { isEmptyProperty, isPropertyFilterWithOperator } from 'lib/components/PropertyFilters/utils'import { TaxonomicFilterGroupType, TaxonomicFilterProps } from 'lib/components/TaxonomicFilter/types'import { objectsEqual } from 'lib/utils/objects'@@ -25,6 +26,7 @@ import { isValidSemverValue } from 'lib/utils/semver'import { projectLogic } from 'scenes/projectLogic'import { groupsModel } from '~/models/groupsModel'+import { extractValidationError } from '~/queries/nodes/InsightViz/utils'import {AnyPropertyFilter,FeatureFlagEvaluationRuntime,@@ -47,6 +49,44 @@ export function isDistinctIdFilter(property: AnyPropertyFilter): boolean {return property.type === PropertyFilterType.Person && property.key === 'distinct_id'}+// What we keep from a failed blast-radius request so the UI can pick a message and decide whether+// a retry is worth offering.+export interface BlastRadiusError {+ status?: number+ code?: string | null+ detail?: string | null+}++export function toBlastRadiusError(error: unknown): BlastRadiusError {+ if (error instanceof ApiError) {+ return { status: error.status, code: error.code, detail: error.detail }+ }+ return {}+}++// A retry only helps when the failure was transient — a timeout, a rate limit (429), or a+// server-side blip. A 512 (too-slow estimate) or a per-query memory limit will fail the same way+// next time, and any other 4xx means the request itself is the problem.+export function isBlastRadiusErrorRetryable(error: BlastRadiusError): boolean {+ if (error.status === 429) {+ return true+ }+ if (error.status !== undefined && error.status >= 400 && error.status < 500) {+ return false+ }+ if (error.status === 512 || error.code === CLICKHOUSE_MEMORY_LIMIT_ERROR_CODE) {+ return false+ }+ return true+}++// The backend sends actionable copy for bad input, a too-slow estimate, and memory-limit+// failures; show it verbatim. Other failures are opaque server faults, so we fall back to a+// generic line.+export function getBlastRadiusErrorMessage(error: BlastRadiusError, pluralName: string): string {+ return extractValidationError(error) ?? `Couldn't estimate how many ${pluralName} match.`+}+// Gates the release-condition save on the same rules the backend enforces, so a bad value is// surfaced inline instead of failing with an opaque 400 on submit.function getPropertyValueError(property: AnyPropertyFilter): string | undefined {@@ -134,7 +174,7 @@ export interface featureFlagReleaseConditionsLogicValues {currentProjectId: number | null // projectLogicaffectedCounts: Record<string, number | undefined>aggregationTargetName: (conditionGroupTypeIndex?: number | null | undefined) => string- blastRadiusErrors: Record<string, boolean>+ blastRadiusErrors: Record<string, BlastRadiusError | undefined>computeBlastRadiusPercentage: (rolloutPercentage: any, sortKey: any) => anydistinctIdNameCache: Record<string, string>distinctIds: string[]@@ -222,7 +262,11 @@ export interface featureFlagReleaseConditionsLogicActions {setAggregationGroupTypeIndex: (value: number | null) => {value: number | null}- setBlastRadiusError: (sortKey: string) => {+ setBlastRadiusError: (+ sortKey: string,+ error: BlastRadiusError+ ) => {+ error: BlastRadiusErrorsortKey: string}setConditionAggregation: (@@ -385,7 +429,7 @@ export const featureFlagReleaseConditionsLogic = kea<featureFlagReleaseConditionsortKey,count,}),- setBlastRadiusError: (sortKey: string) => ({ sortKey }),+ setBlastRadiusError: (sortKey: string, error: BlastRadiusError) => ({ sortKey, error }),calculateBlastRadius: true,calculateBlastRadiusForCondition: (sortKey: string,@@ -615,14 +659,15 @@ export const featureFlagReleaseConditionsLogic = kea<featureFlagReleaseCondition}),},],- // Tracks conditions whose blast-radius estimate failed, so the UI can distinguish a- // genuine error from the still-loading (undefined) state instead of spinning forever.+ // Tracks conditions whose blast-radius estimate failed, keyed by sort_key. Holds the+ // caught error so the UI can explain why (and decide whether a retry is worth offering)+ // instead of just distinguishing failure from the still-loading (undefined) state.blastRadiusErrors: [- {} as Record<string, boolean>,+ {} as Record<string, BlastRadiusError | undefined>,{- setBlastRadiusError: (state, { sortKey }) => ({+ setBlastRadiusError: (state, { sortKey, error }) => ({...state,- [sortKey]: true,+ [sortKey]: error,}),// Cleared when setAffectedCount fires (reset or result); the two counts are always// written together, so listening to setAffectedCount alone is sufficient.@@ -819,10 +864,11 @@ export const featureFlagReleaseConditionsLogic = kea<featureFlagReleaseCondition)actions.setAffectedCount(sortKey, response.affected)actions.setTotalCount(sortKey, response.total)- } catch {- // Surface the failure to the UI rather than masking it as -1, which the- // render path can't tell apart from "still loading".- actions.setBlastRadiusError(sortKey)+ } catch (error) {+ // Keep the caught error so the UI can show what went wrong and hide a retry that+ // can't help, rather than masking it as -1, which the render path can't tell+ // apart from "still loading".+ actions.setBlastRadiusError(sortKey, toBlastRadiusError(error))}},calculateBlastRadius: () => {diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsxindex 0156ad7ce0e0..b61af148836b 100644--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx@@ -13,6 +13,7 @@ import * as trafficControllerPng from '@posthog/brand/hoggies/png/traffic-controimport { IconArchive, IconFunnels, IconInfo, IconPlusSmall, IconRefresh, IconWarning } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import { CLICKHOUSE_MEMORY_LIMIT_ERROR_CODE } from 'lib/api-error'import { pngHoggie } from 'lib/brand/hoggies'import { AccessControlAction } from 'lib/components/AccessControlAction'import { MCPUseCaseCard } from 'lib/components/MCPHint/MCPUseCaseCard'@@ -66,9 +67,6 @@ const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)const HedgehogStampDenied = pngHoggie(stampDeniedPng)const HedgehogTrafficController = pngHoggie(trafficControllerPng)-// Matches ClickHouseQueryMemoryLimitExceeded.default_code on the backend. Keep the two in sync.-const CLICKHOUSE_MEMORY_LIMIT_ERROR_CODE = 'clickhouse_memory_limit_exceeded'-const MEMORY_LIMIT_AI_PROMPT = autoRunMaxPrompt("This insight ran out of memory before it could finish. Help me work out why it's scanning so much data and how to fix it: a shorter date range, narrower filters, or materializing the data.")