Skip to content

Fixes #38373: invalidate about-entity cache after a task transition - #38409

Merged
harsh-vador merged 2 commits into
mainfrom
detail/bug-fix/fixes-38373-invalidate-about-entity-cache-after-a-b419fe
Nov 23, 2026
Merged

harsh-vador merged 2 commits into
mainfrom
detail/bug-fix/fixes-38373-invalidate-about-entity-cache-after-a-b419fe

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #38373

I worked on the inbox incident timeline going stale while the task detail panel stayed open, because acting on an incident from its own panel never refreshed the cached incident status history that drives the Activity stream.

  • Bug: TaskDetailPanel.runTransition advanced only local task state after a successful Ack/Assign/Resolve. The incident status history that the TaskActivityTimeline renders lives in the React Query cache keyed under TASK_ABOUT_ENTITY_QUERY_KEY (useTaskAboutEntity), keyed per task with a 60 s stale time. The panel's other refresh paths (handleCommentMutated, syncTransitionsAfter, the parents' onResolved/onTaskUpdated handlers) invalidate TASK_LIST_QUERY_KEY, TASK_STATUS_COUNTS_QUERY_KEY, INBOX_OPEN_TASK_COUNT_QUERY_KEY and MY_TASKS_QUERY_KEY, but none of them touch the about-entity cache (a grep of the whole UI tree confirmed it is only referenced inside useTaskAboutEntity.ts). With the global QueryClient disabling focus refetch and a mounted query not auto-refetching when it goes stale, the panel kept rendering the pre-transition history indefinitely while the server had already appended the new incident-status record — so the timeline contradicted its own status header. Introduced in commit 36729ad778 (PR Improvement: rebuild the inbox triage task surface #33578).
  • Fix: After setTask(resolved) in runTransition, invalidate the about-entity cache so the mounted useTaskAboutEntity query refetches the latest incident status history in the background (the hook keeps the cached tiles rendered while a refetch is in flight):
    setTask(resolved);
    void queryClient.invalidateQueries({
      queryKey: [TASK_ABOUT_ENTITY_QUERY_KEY],
    });
    This mirrors how TaskDetailPage.handleTaskChanged and TasksTab already invalidate their sibling caches. The invalidation is purely additive — it does not replace the existing list/count invalidations, and the prefix-key form (just [TASK_ABOUT_ENTITY_QUERY_KEY]) matches the existing codebase convention.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Acknowledging an open incident from its detail panel updates the Activity stream to show "acknowledged the incident" while the panel stays mounted (the regression test for the exact bug scenario).
  • Resolving/assigning an incident (the same shared runTransition path) also invalidates the cache for all task types, not just incidents.
  • A failed transition (e.g. server rejects resolveTask) does not invalidate the cache and does not trigger a refetch — the timeline keeps the history it has.

Unit tests

  • Added TaskDetailPanel.cache.test.tsx: renders the real TaskDetailPanel with the real useTaskAboutEntity hook inside a QueryClientProvider (mirroring the app config — 60 s stale time, no focus refetch), mocking only the REST boundary. Asserts that after an ack transition invalidateQueries is called with { queryKey: ['inbox-task-about-entity'] } and getListTestCaseIncidentByStateId is called a second time (mount + post-transition refetch); and that a rejected resolveTask calls neither. The file is separate from TaskDetailPanel.test.tsx because that suite mocks useTaskAboutEntity file-wide, which would hide the cache behaviour.
  • TaskDetailPanel.test.tsx: added a jest.mock('@tanstack/react-query', ...) stub for useQueryClient (the suite mocks useTaskAboutEntity and renders without a QueryClientProvider), preserving the real QueryClient/QueryClientProvider used by renderWithQueryClient. All 116 existing tests still pass.
  • Coverage on TaskDetailPanel.tsx: 98.83% lines (target: 90%); the new invalidation branch is covered.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes — the panel's UI behaviour is unchanged, only its data refresh wiring; the bug is covered by the new Jest regression test that exercises the real React Query cache through the real hook).

Manual testing performed

  • Unit tests, typecheck, lint, and build all pass — the whole InboxPage Jest tree (44 suites / 789 tests) is green; yarn tsc:check matches the baseline (no new errors); ESLint + Prettier + organize-imports + license-header are clean and idempotent on the three changed files.
  • Ran a RED-GREEN proof: commenting out the new invalidateQueries line makes the new regression test fail with Expected: {"queryKey": ["inbox-task-about-entity"]}, Number of calls: 0; restoring it makes both tests pass.
  • Brought up the full local backend (MySQL 8.4 + Elasticsearch 9.3 via docker/development/docker-compose.yml, ran OpenMetadataSetup migrate, then booted openmetadata-service-2.0.0-SNAPSHOT.jar against conf/openmetadata.yaml) and seeded an incident task end-to-end. Confirmed via REST that each transition appends the expected incident-status record to GET /v1/dataQuality/testCases/testCaseIncidentStatus/stateId/{stateId}:
    • before: [New] (1 record)
    • after ack (POST /tasks/{id}/resolve {transitionId:"ack"}): [Ack, New] (2 records), task status: "InProgress"
    • after assign (with {payload:{assignees:[{id,type:"user",name:"admin"}]}}): [Assigned(admin), Ack, New] (3 records)
    • after resolve (with {comment, payload:{testCaseFailureReason:"FalsePositive"}}): [Resolved(resolvedBy=admin), Assigned(admin), Ack, New] (4 records), task status: "Completed"
    • a failed transition (invalid transitionId) leaves the history unchanged at [New], matching the cache-not-invalidated behaviour asserted by the Jest test for the failed path. These are exactly the records getIncidentStatusEvents maps to message.task-event-incident-acknowledged / -assigned / -resolved (already unit-tested in taskTimeline.utils.test.ts).
  • Could not complete the UI click-through against a running browser: the OM UI's basic-auth flow persists its JWT in a service-worker-backed app_state store that Playwright's storageState cannot capture (it only snapshots cookies + localStorage), and blocking /app-worker.js to fall back to localStorage wipes the in-memory token on any page.goto reload. The personal-space /inbox route is also only reachable via the AI-mode sidebar shell, not from the production-bundle default / route (SPA pushState to /inbox bounced to /404). The fix's UI-level behaviour is established by the RED-GREEN Jest regression (above) running against the real useTaskAboutEntity hook in a QueryClientProvider, which asserts both the invalidateQueries call and the second getListTestCaseIncidentByStateId fetch fire immediately after a successful transition.

UI screen recording:

Not applicable — the change is a one-line cache invalidation wiring fix; the UI surface is unchanged and the bug is covered by a Jest regression test against the real React Query hook. (Per the PR template, standalone fixes with no UI surface change may use this N/A.)

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. — N/A, no schema changes.
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). — N/A, no UI feature.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below. — not run; please flag any REVIEW.md findings in review.
  • Decision check: no decision that the next contributor could undo (no schema field, REST path, new default, ordering rule, or rule stated only in this description).

Automatic Fixes PRs can be configured here.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues remain.

Summary

Refreshes cached about-entity data after a successful task transition so the open panel can show the latest incident history.

  • The open task panel refreshes incident history after a successful action.

Reviews (2) · Last reviewed commit: "test(inbox): assert refreshed incident h..." · Reviewed by Greptile

Address review feedback on TaskDetailPanel.cache.test.tsx: keep the
real TaskActivityTimeline instead of mocking it, and assert the
acknowledgment event renders after the ack transition — so the test
fails if the panel stops passing the refetched incident status history
to the timeline, not just if the cache wiring changes.
@harsh-vador harsh-vador added the safe to test Add this label to run secure Github workflows on PRs label Nov 23, 2026
@harsh-vador
harsh-vador enabled auto-merge (squash) November 23, 2026 06:18
@harsh-vador
harsh-vador disabled auto-merge November 23, 2026 06:18
@harsh-vador
harsh-vador merged commit e793b1e into main Nov 23, 2026
56 checks passed
@harsh-vador
harsh-vador deleted the detail/bug-fix/fixes-38373-invalidate-about-entity-cache-after-a-b419fe branch November 23, 2026 07:10
harsh-vador added a commit that referenced this pull request Nov 23, 2026
…tion (backport 2.1 #38409) (#38426)

* fix(inbox): invalidate about-entity cache after a task transition

(cherry picked from commit 22db4b0)

* test(inbox): assert refreshed incident history reaches the timeline

Address review feedback on TaskDetailPanel.cache.test.tsx: keep the
real TaskActivityTimeline instead of mocking it, and assert the
acknowledgment event renders after the ack transition — so the test
fails if the panel stops passing the refetched incident status history
to the timeline, not just if the cache wiring changes.

(cherry picked from commit c622089)

---------

Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Inbox incident timeline doesn’t update after Ack/Assign/Resolve while detail panel stays open

3 participants