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.

fix(data-warehouse): show a fallback when a source icon fails to load (#123761)

Tom Owers612d51e098f9
diff --git a/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.test.tsx b/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.test.tsx
new file mode 100644
index 000000000000..36d97e21a4bf
--- /dev/null
+++ b/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.test.tsx
@@ -0,0 +1,17 @@
+import { fireEvent, render } from '@testing-library/react'
+
+import { HogFunctionIcon } from './HogFunctionIcon'
+
+jest.mock('react-intersection-observer', () => ({ useInView: () => ({ ref: jest.fn(), inView: true }) }))
+
+describe('HogFunctionIcon', () => {
+ it('shows the fallback hedgehog instead of a loading skeleton when the image fails to load', () => {
+ const { container, getByText } = render(<HogFunctionIcon src="/static/services/missing.png" />)
+
+ fireEvent.error(container.querySelector('img')!)
+
+ expect(container.querySelector('img')).toBeNull()
+ expect(container.querySelector('.LemonSkeleton')).toBeNull()
+ getByText('🦔')
+ })
+})
diff --git a/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.tsx b/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.tsx
index 2ede646ef610..0c9b9a7f158e 100644
--- a/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.tsx
+++ b/frontend/src/scenes/hog-functions/configuration/HogFunctionIcon.tsx
@@ -139,6 +139,7 @@ export function HogFunctionIcon({
className?: string
}): JSX.Element {
const [loaded, setLoaded] = useState(false)
+ const [failedSrc, setFailedSrc] = useState<string>()
const { ref: inViewRef, inView } = useInView()
return (
@@ -156,7 +157,7 @@ export function HogFunctionIcon({
>
{!inView && !loaded ? (
<div className="w-full h-full" />
- ) : src ? (
+ ) : src && src !== failedSrc ? (
<>
<img
className={clsx(
@@ -166,6 +167,7 @@ export function HogFunctionIcon({
src={src}
alt="Hog function icon"
onLoad={() => setLoaded(true)}
+ onError={() => setFailedSrc(src)}
/>
{!loaded && <LemonSkeleton className="absolute w-full h-full" />}
</>