Skip to content

: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.

feat(logs, tracing): show inline error icon on failed facet instead of toast (#112594)

Frank Hamand8810b96c0add
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index 926c35efd7f7..e0ebcb612ba6 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -25,6 +25,7 @@ Actions for which we don't want to show error alerts,
mostly to avoid user confusion.
*/
const ERROR_FILTER_ALLOW_LIST = [
+ 'loadFacetValues', // Logs and tracing facets show an inline error icon on the failed facet.
'loadOfflineExperiments', // Offline views provide inline retry states.
'loadOfflineScorerOptions',
'loadOfflineSuggestedScorers',
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx b/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
index c2e2db92aad0..e0bfcbde5d18 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
@@ -1,8 +1,8 @@
import { CSSProperties, useMemo } from 'react'
import { List } from 'react-window'
-import { IconChevronDown, IconChevronRight, IconMinusSmall, IconX } from '@posthog/icons'
-import { LemonButton, LemonCheckbox, LemonInput } from '@posthog/lemon-ui'
+import { IconChevronDown, IconChevronRight, IconMinusSmall, IconWarning, IconX } from '@posthog/icons'
+import { LemonButton, LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
@@ -41,6 +41,8 @@ interface FacetProps {
onRemove?: () => void
/** Disables the remove control (with this explanation) while a custom-facet update is in flight. */
removeDisabledReason?: string
+ /** The facet's latest fetch failed — show an error icon and line instead of pretending the list is fresh (suppresses emptyLabel). */
+ error?: boolean
}
/** A single rail facet: a collapsible field title and its selectable values (multi-select = OR), each with a count. */
@@ -59,6 +61,7 @@ export function Facet({
onToggleCollapsed,
maxHeight,
dimZeroCounts = false,
+ error = false,
onRemove,
removeDisabledReason,
}: FacetProps): JSX.Element {
@@ -82,6 +85,11 @@ export function Facet({
{collapsed ? <IconChevronRight /> : <IconChevronDown />}
<span className="truncate">{title}</span>
</button>
+ {error && !loading && (
+ <Tooltip title="Couldn't load values. Change the filters or expand the facet to retry.">
+ <IconWarning className="text-danger shrink-0" />
+ </Tooltip>
+ )}
{onRemove && (
<LemonButton
size="small"
@@ -105,11 +113,18 @@ export function Facet({
/>
</div>
)}
+ {/* A failed fetch shows inline (options may be stale-but-usable below) rather than blanking the facet. */}
+ {!collapsed && error && !loading && (
+ <div className="px-1 pb-1 text-xs text-danger" data-attr={`logs-facet-${slug}-error`}>
+ Couldn't load values
+ </div>
+ )}
{!collapsed &&
(loading && options.length === 0 ? (
<div className="px-1 text-xs text-muted">Loading…</div>
) : options.length === 0 ? (
- <div className="px-1 text-xs text-muted">{emptyLabel}</div>
+ // The error line above already explains the missing values — don't add "No values".
+ !error && <div className="px-1 text-xs text-muted">{emptyLabel}</div>
) : (
// Dim the list while a refetch is in flight (e.g. typing in search) so there's
// feedback that results are updating, rather than the list silently changing.
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx b/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
index 1fc300969193..5bd4dc2ee141 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
@@ -24,7 +24,9 @@ export interface RailFacetProps {
export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element | null {
// `facet` comes from the memoized visibleFacets selector, so this identity is stable.
const logicProps = useMemo(() => ({ id, facet }), [id, facet])
- const { facetValues, facetValuesLoading, facetSearch, collapsed } = useValues(facetValuesLogic(logicProps))
+ const { facetValues, facetValuesLoading, facetSearch, collapsed, fetchFailed } = useValues(
+ facetValuesLogic(logicProps)
+ )
const { setFacetSearch } = useActions(facetValuesLogic(logicProps))
const { filterGroup } = useValues(logsViewerFiltersLogic({ id }))
const { toggleFacetValue, toggleFacetCollapsed } = useActions(facetRailLogic({ id }))
@@ -89,6 +91,7 @@ export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element |
collapsed={collapsed}
onToggleCollapsed={onToggleCollapsed}
dimZeroCounts
+ error={fetchFailed}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
@@ -110,6 +113,7 @@ export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element |
collapsed={collapsed}
onToggleCollapsed={onToggleCollapsed}
maxHeight={facet.maxHeight}
+ error={fetchFailed}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
index b6856adf290f..32c6e7c10e4f 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
@@ -72,6 +72,17 @@ describe('facetValuesLogic', () => {
expect(selectedLogic.values.facetValuesLoading).toBe(false)
})
+ it('a failed fetch shows in place and clears on the next fetch', async () => {
+ mockFacetValues.mockRejectedValueOnce(new Error('facet values failed'))
+ const logic = mountFacet(SERVICE)
+ await expectLogic(logic).toDispatchActions(['loadFacetValuesFailure'])
+ expect(logic.values.fetchFailed).toBe(true)
+
+ logic.actions.setFacetSearch('api')
+ await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])
+ expect(logic.values.fetchFailed).toBe(false)
+ })
+
it('a type-ahead search refetches this facet with the search term', async () => {
const logic = mountFacet(SERVICE)
await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
index d9c6743a6843..211f41b21c23 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
@@ -38,6 +38,7 @@ export interface facetValuesLogicValues {
facetSearch: string
facetValues: _LogFacetValueApi[]
facetValuesLoading: boolean
+ fetchFailed: boolean
fetchSignature: string
fetchedSignature: string | null
scopeSignature: string
@@ -159,6 +160,15 @@ export const facetValuesLogic = kea<facetValuesLogicType>([
clearFetchedSignature: () => null,
},
],
+ // Drives this facet's inline error state, so one broken facet shows in place rather than
+ // as a global toast.
+ fetchFailed: [
+ false,
+ {
+ loadFacetValuesSuccess: () => false,
+ loadFacetValuesFailure: () => true,
+ },
+ ],
}),
loaders(({ props, values }) => ({
diff --git a/products/tracing/frontend/components/FacetRail/Facet.tsx b/products/tracing/frontend/components/FacetRail/Facet.tsx
index 163cdb9488e0..588a9b42ab14 100644
--- a/products/tracing/frontend/components/FacetRail/Facet.tsx
+++ b/products/tracing/frontend/components/FacetRail/Facet.tsx
@@ -1,8 +1,8 @@
import { CSSProperties, useMemo } from 'react'
import { List } from 'react-window'
-import { IconChevronDown, IconChevronRight, IconMinusSmall, IconX } from '@posthog/icons'
-import { LemonButton, LemonCheckbox, LemonInput } from '@posthog/lemon-ui'
+import { IconChevronDown, IconChevronRight, IconMinusSmall, IconWarning, IconX } from '@posthog/icons'
+import { LemonButton, LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
@@ -90,6 +90,11 @@ export function Facet({
{collapsed ? <IconChevronRight /> : <IconChevronDown />}
<span className="truncate">{title}</span>
</button>
+ {error && !loading && (
+ <Tooltip title="Couldn't load values. Change the filters or expand the facet to retry.">
+ <IconWarning className="text-danger shrink-0" />
+ </Tooltip>
+ )}
{onRemove && (
<LemonButton
size="small"