Skip to content

Fixes 34616: Hide incidents of deleted test cases in the Incident Manager - #36690

Merged
ShaileshParmar11 merged 16 commits into
mainfrom
fix/incident-listing-per-incident-deleted-scope
Nov 5, 2026
Merged

ShaileshParmar11 merged 16 commits into
mainfrom
fix/incident-listing-per-incident-deleted-scope

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #34616

I worked on this because 2.1 release testing of the incidents found that the classic Incident Manager lists incidents of soft-deleted test cases. /search/list ignored include: incident documents have no deleted field, and soft-deleting a test case never touched its incidents' documents.

Changes:

  • Each index declares its deleted field. EntityIndexCapability carries deletedField instead of a boolean: deleted for entities and for time series whose schema has it (agent and MCP executions), none for the other time series. Incidents declare testCase.deleted (TestCaseResolutionStatusRepository.getSearchDeletedField). Two places read it:

    • SearchRepository.softDeleteOrRestoredChildren runs one SoftDeleteScript per field, so a soft delete or restore of a table, schema, database, service, test suite or test case also sets testCase.deleted on the incidents under it. This is the same synchronous call on the same parent match.
    • SearchListFilter.getIncludeCondition filters on the field the entity declares. non-deleted is now must_not <field>: true for every entity, so a document without the flag counts as not deleted.
  • TestCaseResolutionStatusIndex writes every ancestor that soft delete matches on (testSuite, database, databaseSchema, service, alongside table). It used to rebuild the test case without its suite and then read the suite from the rebuilt copy, so none of those were written. The strict read strips the new fields.

  • EntityTimeSeriesRepository.groupScopeFilter keeps the caller's include. Before, it always defaulted to non-deleted, which would have made include=deleted (sent by a deleted table's incident tab) match nothing.

  • Child delete/restore propagation also updates each compatible child type's registered staged index. Staged targets are resolved by canonical index name, so a script for testCase.deleted cannot reach a type that uses deleted or has no deletion flag.

Recorded in ADR:2026-10-30-incidents-are-scoped-by-their-test-cases-deleted-flag.

Type of change:

  • Bug fix

High-level design:

  • Out of scope: one open incident per test case. An earlier revision also refused a second open incident for a test case (in TaskRepository.prepare and getOrCreateIncident). Per review (@TeddyCr), that is left out until the workflow-based incident code is checked for what it already enforces. So a group's count can still differ from its drawer when a test case holds two open incidents.
  • Alternatives rejected:
    • Close or hide incidents when a test case is soft-deleted. This would change the incident data, and a restore would have to reopen them.
    • A per-caller deleted-field override on SearchListFilter. The group scope filter builds its own filter, so a caller-set field would have to be copied along. The capability is one declaration, read by both the write and the read side.
  • Existing bug, not fixed here. On main, soft-deleting a schema or database that holds a test case returns 404 (testSuite instance … not found) before search is touched, so those ancestor levels have no IT yet.
  • Rollout. Incident documents of test cases soft-deleted before this change keep testCase.deleted: false until testCaseResolutionStatus is reindexed. A reindex rebuilds them with the right flag. Delete and restore also update compatible staged indices. This does not make concurrent reindex bulk writes transactional with those updates.

Tests:

Use cases covered

  • Soft-deleting a test case hides its incidents from the classic listing; include=deleted lists them.
  • Soft-deleting a table or test suite hides its test cases' incidents (cascade path); restoring brings them back.
  • Agent and MCP executions keep their own deleted filter.
  • include reaches the latest aggregation's scope filter.

Unit tests

  • I added unit tests for the new/changed logic.
  • SearchListFilterTest#testResolutionStatusCondition_scopesByTestCaseDeleted; #testSimpleGetCondition and #testGetFilterQueryReturnsOnlyQuerySection updated to the must_not form.
  • SoftDeleteScriptTest#setsAnEmbeddedFieldOnlyOnIndexesThatNameIt
  • SearchRepositoryBehaviorTest#softDeleteOrRestoredChildrenFlagsTheIncidentsOfASoftDeletedTestCase and #...UnderARestoredService; two existing tests narrowed to the deleted script.
  • TestCaseResolutionStatusRepositoryTest#searchOnlyFieldsOfAnIndexedIncidentAreStrippedBeforeTheStrictRead now builds the doc through the test suite branch, covering the new ancestor fields.
  • EntityTimeSeriesRepositoryPaginationTest#testScopeFilterCarriesTheInclude
  • EntityTimeSeriesSearchDeletedFieldTest: a time series with its own deleted (agent and MCP executions) keeps it, one without declares none, an incident declares testCase.deleted.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/.
  • TestCaseSoftDeleteSearchIT#softDeletingTestCaseDoesNotPollutePropagatedTimeSeriesDocs (extended with the include assertions), #softDeletingAndRestoringTableScopesItsIncidents and #softDeletingAndRestoringTestSuiteScopesItsIncidents (new; fail on main).

Java test run: targeted local runs on 45a720a517d; full IT suites in CI on an earlier head

  • Head: 45a720a517d. It removes the one-open-incident guard (TaskRepository, getOrCreateIncident) and its two ITs; the search changes are unchanged since the CI runs below.
Step Where Scope Tests Failed Result
unit local, 45a720a517d SearchListFilterTest, SearchRepositoryBehaviorTest, SoftDeleteScriptTest, EntityIndexCapabilityRegistryTest, IndexMappingValidatorTest, TestCaseResolutionStatusTest, TaskRepositoryTest, EntityTimeSeriesRepositoryPaginationTest, EntityTimeSeriesSearchDeletedFieldTest, IncidentHistorySqlTest 260 0 passed
integration local, 45a720a517d mysql-elasticsearch · parallel: IncidentTaskIntegrationIT, TestCaseSoftDeleteSearchIT, IncidentGroupsIT, StaleIncidentStatusIT, IncidentPaginationIT, TestCaseResolutionStatus*IT, TaskResourceIT 402 (31 skipped) 0 passed
integration local, 49c8273c5f3 mysql-elasticsearch · parallel: AgentExecutionResourceIT, McpExecutionResourceIT, McpSearchIT, IncidentTaskIntegrationIT, TestCaseSoftDeleteSearchIT 49 (3 skipped) 0 passed
search-it local, 49c8273c5f3 postgres-opensearch, 28 classes 73 0 passed
integration CI, 7efde665d2a MySQL + Elasticsearch, every lane full suite 0 passed
integration CI, 7efde665d2a PostgreSQL + OpenSearch, every lane full suite 0 passed

Skips are existing BaseEntityIT skips. The 17 nightly scale and UI ITs were not run.

Staged-index regression verification (56c02323489)

  • Added TestCaseSoftDeleteSearchIT#tableDeleteAndRestoreReachOnlyCompatibleStagedIndices: real table delete and restore, serving incident listing, staged test case and incident flags, and isolation of a staged test-result document. A sentinel embedded field catches scripts sent to the wrong type.
  • Before the fix: the new regression failed on MySQL/Elasticsearch because the staged document retained deleted=false after deleting its table. After the fix: all four TestCaseSoftDeleteSearchIT tests passed on MySQL/Elasticsearch.
  • SearchRepositoryBehaviorTest: 155 passed. The four affected MCP unit classes: 148 passed. Spotless and commit/push hooks passed.
  • CI passed on this commit: service unit tests, Collate compatibility, and Java formatting.
  • Full local service unit suite: 16,126 tests, 1 failure, 3 skipped. CompiledTextTest.oneSourceTextIsWhatTheBuilderHasAlwaysWritten expected AND but received null; the same failure reproduced in a clean worktree at the original PR head 9648a011788 when running the alerting-definition test group.
  • Local integration limits: Docker OOM-killed Elasticsearch during the broad lane and OpenSearch during the focused restore scenario. The broad lane was stopped after its engine died. The focused OpenSearch run ended with 3 passing tests and 1 connection-reset error; it is not counted as a pass. Other development/Testcontainers workloads share the local Docker VM, so the remaining broad/search-specific checks were moved to CI.
  • Full CI coverage on 56c02323489, pending: MySQL + Elasticsearch, PostgreSQL + OpenSearch, and search-specific suite / JavaUIIT workflow. The last workflow includes the search-it classes selected by the affected-test planner.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable: no UI changes. make playwright_affected selects the search and incident specs because SearchRepository changed. They were not run locally and run in the merge queue.

Manual testing performed

Not run against a live stack. The scenario from the release-testing page is reproduced as the integration tests above.

UI screen recording:

Not applicable — backend bug fix.

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: not applicable, no schema changes.

  • For a UI feature or feature task: not applicable.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md. A failed flag update is not retried for incident documents; a reindex repairs them (ADR says so).

  • Decision check: adds docs/decisions/2026-10-30-incidents-are-scoped-by-their-test-cases-deleted-flag.md.

  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Oct 30, 2026
…est cases

- Latest incident listings keep the latest record of each incident (stateId) instead of each
  test case, so a group's drill-down, drawer and bulk actions match the group count when a test
  case holds two open incidents.
- The search listing scopes include on the embedded testCase.deleted, and a soft delete or
  restore of a test case or any parent updates that flag on the incident documents under it.
- The latest aggregation's scope filter carries the caller's include.
- The testCase.deleted update goes through the same synchronous update as the soft-delete
  cascade, so a failure reaches the retry queue and a quick restore cannot race it.
- TestCaseSoftDeleteSearchIT restores the table and checks the incident returns.
- The decision record states that the classic search listing stays per test case.
@ShaileshParmar11
ShaileshParmar11 force-pushed the fix/incident-listing-per-incident-deleted-scope branch from c600f96 to 598fa2f Compare November 2, 2026 05:30
@ShaileshParmar11
ShaileshParmar11 marked this pull request as ready for review November 2, 2026 06:03
Copilot AI balanced review requested due to automatic review settings November 2, 2026 06:03
@ShaileshParmar11
ShaileshParmar11 requested review from a team as code owners November 2, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Incident search updates leave cascade-deleted test cases visible after ancestor deletion and fail to update staged indexes, allowing reindex promotion to restore stale deletion flags.

2 open issues
What changed in this PR

This PR addresses grouped-incident count mismatches and deleted-test-case visibility in OpenMetadata’s Incident Manager.

Changes:

  • Returns one latest database record per incident, while preserving the classic search listing’s per-test-case behavior.
  • Filters incident search results by the embedded test case’s deletion flag and propagates delete/restore updates.
  • Adds regression coverage and records the listing contracts and reindex implications.
File Description
openmetadata-ui/​src/​main/​resources/​ui/​src/​pages/​TableDetailsPageV1/​TableDetailsPageV1.tsx Updates comments describing latest-incident filtering; no functional UI change.
openmetadata-service/​src/​test/​java/​org/​openmetadata/​service/​search/​SearchRepositoryBehaviorTest.java Tests incident deletion-flag propagation calls.
openmetadata-service/​src/​test/​java/​org/​openmetadata/​service/​jdbi3/​TestCaseResolutionStatusTimeSeriesDaoLatestTest.java Updates partition expectations to stateId.
openmetadata-service/​src/​test/​java/​org/​openmetadata/​service/​jdbi3/​SearchListFilterTest.java Tests search deletion scoping for each include mode.
openmetadata-service/​src/​test/​java/​org/​openmetadata/​service/​jdbi3/​EntityTimeSeriesRepositoryPaginationTest.java Tests preservation of include in aggregation scope.
openmetadata-service/​src/​main/​java/​org/​openmetadata/​service/​search/​SearchRepository.java Propagates embedded test-case deletion flags to incidents.
openmetadata-service/​src/​main/​java/​org/​openmetadata/​service/​search/​SearchListFilter.java Applies incident search filters using testCase.deleted.
openmetadata-service/​src/​main/​java/​org/​openmetadata/​service/​jdbi3/​TimeSeriesDAOs.java Partitions latest incident listings by stateId.
openmetadata-service/​src/​main/​java/​org/​openmetadata/​service/​jdbi3/​EntityTimeSeriesRepository.java Carries caller deletion scope into grouped search.
openmetadata-integration-tests/​src/​test/​java/​org/​openmetadata/​it/​tests/​TestCaseSoftDeleteSearchIT.java Tests incident visibility after test-case deletion and table delete/restore.
openmetadata-integration-tests/​src/​test/​java/​org/​openmetadata/​it/​tests/​IncidentGroupsIT.java Tests drill-down completeness for multiple open incidents on one test case.
docs/​decisions/​2026-10-30-incident-listings-are-per-incident-and-scoped-by-the-test-case-deleted-flag.md Records listing contracts, deletion scoping and reindex implications.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
80.97% (137065/169264) 67.88% (49184/72453) 70.93% (27686/39029)

…the staged index

- TestCaseResolutionStatusIndex rebuilt the test case without its test suite and then read the
  suite from the rebuilt copy, so testSuite, database, databaseSchema and service were never
  written. The doc now carries them all (from the resolved table and the original suite
  reference), and the strict read strips them and certification.
- The incident testCase.deleted update goes through getWriteFanoutTargets, so a reindex's staged
  index gets it too.
- TestCaseSoftDeleteSearchIT soft-deletes and restores the basic test suite.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 06:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Bulk assignment does not preserve the selected incident’s stateId, causing it to update a newer, unselected incident chain instead of the older chain shown in the filtered group.

2 open issues
1 resolved since last review

Review effort: Balanced

@ShaileshParmar11

ShaileshParmar11 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Superseded. This comment held the details of a full make java_affected_run on 5ee88290e7d, which recorded one unit failure, JobRecoveryOrphanDetectionTest#updatedAtAtThresholdIsOrphaned. That is a timing flake in code this PR does not touch, and it passes rerun alone. The search-it step ran 0 tests because its OpenSearch container was OOMKilled.

The PR description now lists the targeted runs on the final code (ce5d5a97f1c): incident ITs 107/107 and search-it 73/73.

…s latest

A test case can hold more than one open incident, and the grouped view now
lists each of them, but a status write was keyed by test case alone: a bulk
change picked from an older incident updated the newer one. The create request
takes an optional stateId; the server applies the status to that incident, after
checking it belongs to the request's test case, and rejects one sent with New.
A status for an incident without its own task no longer moves the open task of
another incident. The grouped view's bulk actions and the reopen action send
the incident's stateId.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 09:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new guard rejects bulk severity-only edits for incidents in New when the UI supplies the current stateId, blocking valid severity updates.

2 open issues
1 resolved since last review

Review effort: Balanced

A severity change re-sends the incident's current status, now with its stateId,
so an incident still in New sent New plus a stateId, which the previous commit
rejected before the severity path ran. New is now rejected only when it names a
resolved incident, where it would start a new incident under the old stateId;
on an open incident it only restates the status.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:05
* or promoting it would bring the old flag back. The retry of a failed soft delete does not
* reach incident documents; a reindex of testCaseResolutionStatus repairs them.
*/
private void softDeleteOrRestoreIncidentTestCases(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here, should this entity specific method live in searchRepository, and should it be a per entity override?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it per entity in 7efde66: softDeleteOrRestoreIncidentTestCases is gone. softDeleteOrRestoredChildren groups the child aliases by the deletedField their capability declares and runs one SoftDeleteScript per field, so incidents get testCase.deleted through the same generic path as deleted on entities. The only incident-specific bit is the repository's getSearchDeletedField override.

A test case could hold two open incidents: a failing test reused only an
open incident task, so an open incident started through the status API got
a second chain, and POST /tasks could start one at any time. Refuse a new
incident task while the test case has another open incident, and let a
failure join an open incident that has no task. This replaces the
per-stateId listing and the stateId on status writes, which are reverted.

Each search index now declares the field that marks its documents deleted
on its EntityIndexCapability (incidents: testCase.deleted). Soft-delete
propagation and the search list include filter both read it, replacing the
incident-specific code in SearchRepository and SearchListFilter.
@ShaileshParmar11 ShaileshParmar11 changed the title Fixes 34616: List every open incident in a group and hide incidents of deleted test cases Fixes 34616: Keep one open incident per test case and hide incidents of deleted test cases Nov 3, 2026
Copilot AI balanced review requested due to automatic review settings November 3, 2026 06:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

The include filter now reads the deleted field from the entity's index
capability. Time series registered with none, so agent and MCP executions,
whose schemas have a deleted field, lost their filter. Declare deleted for
any time series whose schema has it.
Copilot AI balanced review requested due to automatic review settings November 3, 2026 08:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Review asked to ship without it until the workflow-based incident code is
checked for what it already enforces. Reverts the TaskRepository guard, the
getOrCreateIncident join and their ITs; the ADR keeps the deleted-flag
scoping only.
Copilot AI balanced review requested due to automatic review settings November 5, 2026 04:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@ShaileshParmar11 ShaileshParmar11 changed the title Fixes 34616: Keep one open incident per test case and hide incidents of deleted test cases Fixes 34616: Hide incidents of deleted test cases in the Incident Manager Nov 5, 2026
Copilot AI balanced review requested due to automatic review settings November 5, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 13:40
@ShaileshParmar11
ShaileshParmar11 enabled auto-merge (squash) November 5, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · Changes search soft-delete propagation and incident filtering; incorrect embedded flags could hide active incidents or expose incidents of deleted test cases.

Hides incidents of soft-deleted test cases in the classic Incident Manager by declaring a per-index deleted field, cascading the flag to incidents on soft delete or restore of parent entities, and preserving the caller's include filter in the time series group scope. Bulk severity changes on New incidents are now rejected, addressing the resolved finding. No open issues remain.

✅ 1 closed
✅ Bug: Bulk severity change on a New incident is now rejected

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java:305-319 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java:329-343 📄 openmetadata-ui/src/main/resources/ui/src/components/observability/IncidentManager/IncidentGroups/IncidentGroupBulk.utils.ts:79-93 📄 openmetadata-ui/src/main/resources/ui/src/components/observability/IncidentManager/IncidentGroups/IncidentGroupBulk.utils.test.ts:169-176
For a severity change, toEntry (IncidentGroupBulk.utils.ts:83-94) sends the incident's current status again, and it now also sends its stateId. When the incident is still New, the entry carries New plus a stateId. applyBulkStatus calls incidentToUpdate, which runs rejectNewNamingAnIncident before the same-status/severity branch is checked, so it throws "A New status starts an incident and cannot name one". Before this commit the entry reached updateSeverity. The UI unit test at IncidentGroupBulk.utils.test.ts:169-176 builds exactly this entry (New + state-fresh + Severity1), so bulk severity edits on fresh incidents now always fail. The IT doesn't catch it because it sets severity only on an Ack incident.

Fix: only reject New with a stateId when it would actually create a record. Take the check out of incidentToUpdate and call it in storeInternal and in the non-severity branches of applyBulkStatus, so a same-status severity edit can still name its incident.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@ShaileshParmar11
ShaileshParmar11 merged commit f2ea9a6 into main Nov 5, 2026
81 of 89 checks passed
@ShaileshParmar11
ShaileshParmar11 deleted the fix/incident-listing-per-incident-deleted-scope branch November 5, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouped incidents in the AI-mode Incident Manager

3 participants