Repository navigation
Fixes 34616: Hide incidents of deleted test cases in the Incident Manager - #36690
Conversation
…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.
c600f96 to
598fa2f
Compare
There was a problem hiding this comment.
🟡 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
…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.
There was a problem hiding this comment.
🟡 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
|
Superseded. This comment held the details of a full The PR description now lists the targeted runs on the final code ( |
…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.
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.
| * 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( |
There was a problem hiding this comment.
Same remark here, should this entity specific method live in searchRepository, and should it be a per entity override?
There was a problem hiding this comment.
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.
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
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.
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.
…per-incident-deleted-scope
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
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |


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/listignoredinclude: incident documents have nodeletedfield, and soft-deleting a test case never touched its incidents' documents.Changes:
Each index declares its deleted field.
EntityIndexCapabilitycarriesdeletedFieldinstead of a boolean:deletedfor entities and for time series whose schema has it (agent and MCP executions), none for the other time series. Incidents declaretestCase.deleted(TestCaseResolutionStatusRepository.getSearchDeletedField). Two places read it:SearchRepository.softDeleteOrRestoredChildrenruns oneSoftDeleteScriptper field, so a soft delete or restore of a table, schema, database, service, test suite or test case also setstestCase.deletedon the incidents under it. This is the same synchronous call on the same parent match.SearchListFilter.getIncludeConditionfilters on the field the entity declares.non-deletedis nowmust_not <field>: truefor every entity, so a document without the flag counts as not deleted.TestCaseResolutionStatusIndexwrites every ancestor that soft delete matches on (testSuite,database,databaseSchema,service, alongsidetable). 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.groupScopeFilterkeeps the caller'sinclude. Before, it always defaulted tonon-deleted, which would have madeinclude=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.deletedcannot reach a type that usesdeletedor has no deletion flag.Recorded in
ADR:2026-10-30-incidents-are-scoped-by-their-test-cases-deleted-flag.Type of change:
High-level design:
TaskRepository.prepareandgetOrCreateIncident). 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.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.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.testCase.deleted: falseuntiltestCaseResolutionStatusis 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
include=deletedlists them.deletedfilter.includereaches the latest aggregation's scope filter.Unit tests
SearchListFilterTest#testResolutionStatusCondition_scopesByTestCaseDeleted;#testSimpleGetConditionand#testGetFilterQueryReturnsOnlyQuerySectionupdated to themust_notform.SoftDeleteScriptTest#setsAnEmbeddedFieldOnlyOnIndexesThatNameItSearchRepositoryBehaviorTest#softDeleteOrRestoredChildrenFlagsTheIncidentsOfASoftDeletedTestCaseand#...UnderARestoredService; two existing tests narrowed to thedeletedscript.TestCaseResolutionStatusRepositoryTest#searchOnlyFieldsOfAnIndexedIncidentAreStrippedBeforeTheStrictReadnow builds the doc through the test suite branch, covering the new ancestor fields.EntityTimeSeriesRepositoryPaginationTest#testScopeFilterCarriesTheIncludeEntityTimeSeriesSearchDeletedFieldTest: a time series with its owndeleted(agent and MCP executions) keeps it, one without declares none, an incident declarestestCase.deleted.Backend integration tests
openmetadata-integration-tests/.TestCaseSoftDeleteSearchIT#softDeletingTestCaseDoesNotPollutePropagatedTimeSeriesDocs(extended with the include assertions),#softDeletingAndRestoringTableScopesItsIncidentsand#softDeletingAndRestoringTestSuiteScopesItsIncidents(new; fail on main).Java test run: targeted local runs on
45a720a517d; full IT suites in CI on an earlier head45a720a517d. It removes the one-open-incident guard (TaskRepository,getOrCreateIncident) and its two ITs; the search changes are unchanged since the CI runs below.45a720a517d45a720a517d49c8273c5f349c8273c5f37efde665d2a7efde665d2aSkips are existing
BaseEntityITskips. The 17 nightly scale and UI ITs were not run.Staged-index regression verification (
56c02323489)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.deleted=falseafter deleting its table. After the fix: all fourTestCaseSoftDeleteSearchITtests passed on MySQL/Elasticsearch.SearchRepositoryBehaviorTest: 155 passed. The four affected MCP unit classes: 148 passed. Spotless and commit/push hooks passed.CompiledTextTest.oneSourceTextIsWhatTheBuilderHasAlwaysWrittenexpectedANDbut receivednull; the same failure reproduced in a clean worktree at the original PR head9648a011788when running the alerting-definition test group.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
Playwright (UI) tests
make playwright_affectedselects the search and incident specs becauseSearchRepositorychanged. 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