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(workflows): incident replay banner missed workflows in large projects (#86189)

Meikel Ratz90d0c2ad8187
diff --git a/products/workflows/frontend/workflowsIncidentReplayLogic.test.ts b/products/workflows/frontend/workflowsIncidentReplayLogic.test.ts
new file mode 100644
index 000000000000..4e65a366eb33
--- /dev/null
+++ b/products/workflows/frontend/workflowsIncidentReplayLogic.test.ts
@@ -0,0 +1,69 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { workflowsIncidentReplayLogic } from './workflowsIncidentReplayLogic'
+
+const AFFECTED_FLOW_ID = '019d244c-42c9-0000-ec6c-752c8b265c4f'
+const DELETED_FLOW_ID = '019d9146-223a-0000-8165-1a3489e88b3d'
+const FLAKY_FLOW_ID = '019f3834-8dbd-0000-4b19-073031109b21'
+
+describe('workflowsIncidentReplayLogic', () => {
+ let logic: ReturnType<typeof workflowsIncidentReplayLogic.build>
+ let remainingCount: number
+
+ beforeEach(() => {
+ remainingCount = 12
+ useMocks({
+ post: {
+ '/api/environments/:team_id/query/:query_kind/': () => [
+ 200,
+ {
+ results: [
+ [224, AFFECTED_FLOW_ID],
+ [29, FLAKY_FLOW_ID],
+ [3, DELETED_FLOW_ID],
+ ],
+ },
+ ],
+ },
+ get: {
+ '/api/projects/:team_id/hog_flows/:id/': (req) => {
+ if (req.params.id === AFFECTED_FLOW_ID) {
+ return [200, { id: AFFECTED_FLOW_ID, name: 'Order confirmation', user_access_level: 'editor' }]
+ }
+ if (req.params.id === FLAKY_FLOW_ID) {
+ return [500, { detail: 'Internal server error.' }]
+ }
+ return [404, { detail: 'Not found.' }]
+ },
+ '/api/projects/:team_id/hog_flows/:id/invocation_results_count/': () => [
+ 200,
+ { count: remainingCount },
+ ],
+ },
+ })
+ initKeaTests()
+ logic = workflowsIncidentReplayLogic()
+ logic.mount()
+ })
+
+ it('resolves workflows by id, drops 404s, keeps rows whose retrieve fails transiently', async () => {
+ await expectLogic(logic, () => logic.actions.loadAffectedWorkflows()).toDispatchActions([
+ 'loadAffectedWorkflowsSuccess',
+ ])
+ expect(logic.values.affectedWorkflows).toEqual([
+ { id: AFFECTED_FLOW_ID, name: 'Order confirmation', failedCount: 12, userAccessLevel: 'editor' },
+ { id: FLAKY_FLOW_ID, name: '', failedCount: 12, userAccessLevel: null },
+ ])
+ })
+
+ it('drops workflows whose remaining failed count is zero', async () => {
+ remainingCount = 0
+ await expectLogic(logic, () => logic.actions.loadAffectedWorkflows()).toDispatchActions([
+ 'loadAffectedWorkflowsSuccess',
+ ])
+ expect(logic.values.affectedWorkflows).toEqual([])
+ })
+})
diff --git a/products/workflows/frontend/workflowsIncidentReplayLogic.ts b/products/workflows/frontend/workflowsIncidentReplayLogic.ts
index 313690cae3d2..518c308cf2f4 100644
--- a/products/workflows/frontend/workflowsIncidentReplayLogic.ts
+++ b/products/workflows/frontend/workflowsIncidentReplayLogic.ts
@@ -12,9 +12,10 @@ import { AccessControlLevel } from '~/types'
import {
hogFlowsInvocationResultsCountRetrieve,
- hogFlowsList,
hogFlowsRerunCreate,
+ hogFlowsRetrieve,
} from 'products/workflows/frontend/generated/api'
+import type { HogFlowApi } from 'products/workflows/frontend/generated/api.schemas'
// The window of the 2026-08-17 email send incident (UTC), padded around the first and last
// observed failures. Both the affected-workflow lookup and the rerun filter use it, so a
@@ -137,13 +138,32 @@ export const workflowsIncidentReplayLogic = kea<workflowsIncidentReplayLogicType
return []
}
- // Keep only workflows the list endpoint returns: it applies object-level
- // access control, so this never names a workflow the user can't see, and it
- // drops deleted workflows, which can't be replayed anyway.
+ // Fetch each affected workflow by ID rather than intersecting with the list
+ // endpoint: the list caps at a page size, so in projects with more workflows
+ // than one page the affected ones can fall outside it and silently drop off
+ // the banner. Only a definitive 403 (no access) or 404 (hard-deleted, can't
+ // be replayed) drops a row - the same gates the list applied. A transient
+ // retrieve failure (network, 429, 5xx) keeps the row with fallback fields,
+ // so a blip never hides the recovery path.
const projectId = String(values.currentProjectId)
- const flows = await hogFlowsList(projectId, { limit: 300 })
- const flowsById = new Map((flows.results ?? []).map((flow) => [flow.id, flow]))
- const visible = affected.filter((row) => flowsById.has(row.id))
+ const dropped = new Set<string>()
+ const flows = await Promise.all(
+ affected.map(async (row) => {
+ try {
+ return await hogFlowsRetrieve(projectId, row.id)
+ } catch (error) {
+ const status = (error as { status?: number }).status
+ if (status === 403 || status === 404) {
+ dropped.add(row.id)
+ }
+ return null
+ }
+ })
+ )
+ const flowsById = new Map(
+ flows.filter((flow): flow is HogFlowApi => flow !== null).map((flow) => [flow.id, flow])
+ )
+ const visible = affected.filter((row) => !dropped.has(row.id))
if (visible.length === 0) {
return []