Skip to content

Restoring a soft-deleted TestCase that has incident history succeeds - #36754

Merged
TeddyCr merged 2 commits into
open-metadata:mainfrom
TeddyCr:taskr/restoring-soft-deleted-testcase-has-incident-0142
Nov 3, 2026
Merged

TeddyCr merged 2 commits into
open-metadata:mainfrom
TeddyCr:taskr/restoring-soft-deleted-testcase-has-incident-0142

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Restoring a soft-deleted TestCase with incident history (TestCase --PARENT_OF--> testCaseResolutionStatus edges) failed with a 404 "Entity repository for testCaseResolutionStatus not found" because restoreChildren looked up a repository for the time-series child. Time-series entities are registered — in their own registry, ENTITY_TS_REPOSITORY_MAP, consulted via Entity.getEntityTimeSeriesRepository() — but not in ENTITY_REPOSITORY_MAP, which is the only map Entity.getEntityRepository(type) consults, so that lookup throws (#35826). The fix adds an early skip for time-series children in restoreChildren in EntityRepository.java, mirroring the filter the bulk path already applies in dispatchToContainedChildren and that deleteChildren applies on the delete side — subtree soft-delete/restore cascades never touch time-series children, so skipping (rather than dispatching to the time-series repository) is the symmetric fix. Because create-or-update on a soft-deleted entity funnels through the same applyPut → restoreEntity → restoreChildren path as PUT /v1/dataQuality/testCases/restore, this one change fixes both failing flows. Two regression tests were added to TestCaseResourceIT, one for the restore endpoint and one for create-or-update on a soft-deleted case. Each test creates a resolution-status record directly and asserts its PARENT_OF edge exists (count == 1) before soft-deleting, so it cannot pass vacuously. Reviewers should start with the change in restoreChildren and check that the skip condition matches the dispatchToContainedChildren filter.

Implementer's note: restoreChildren now skips time-series children so soft-deleted test cases with incidents restore via both /restore and upsert; the two new integration tests failed before the fix and pass after it, and all planned checks pass.

Plan

  1. In the implementation worktree (branched from up-to-date local main), reproduce RED first: add the regression tests to TestCaseResourceIT.java and run them on unfixed code, confirming the 404 "Entity repository for testCaseResolutionStatus not found" reported in issue Restoring a soft-deleted TestCase with incidents fails: "Entity repository for testCaseResolutionStatus not found" #35826.
  2. In openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java, extend restoreChildren(UUID, String): inside the idsByType loop, add an early if (Entity.isTimeSeriesEntity(entry.getKey())) { continue; } before the repository lookup — mirroring the exact filter the bulk path uses in dispatchToContainedChildren and that deleteChildren applies on delete. Keep the added comment minimal, citing the dispatchToContainedChildren parity and the TestCase --PARENT_OF--> testCaseResolutionStatus case. No other changes: do not touch dispatchToContainedChildren, ENTITY_REPOSITORY_MAP/ENTITY_TS_REPOSITORY_MAP, or any REST/schema/relationship code. This one fix covers both failing paths, since PUT create-or-update on a soft-deleted entity funnels through applyPut → restoreEntity → the same restoreChildren.
  3. Regression tests in openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResourceIT.java, following the shape of test_testCaseSoftDeleteAndRestore_200_OK and the direct resolution-status creation pattern of test_hardDeleteReapsResolutionStatusChildren:
    a. test_testCaseSoftDeleteAndRestoreWithIncident_200_OK — create a test case, create a resolution-status child, soft-delete it, then restoreEntity(id) (PUT /v1/dataQuality/testCases/restore); assert 200 and getEntity returns the case with deleted=false.
    b. test_testCaseCreateOrUpdateOnSoftDeletedWithIncident_200_OK — same setup, then re-send the create request via updateEntity (the PUT create-or-update path); assert 200 and the entity restored.
    Both use the addResolutionStatusChild helper, which creates a New resolution-status record directly (record + TestCase --PARENT_OF--> testCaseResolutionStatus edge are written synchronously in one transaction) and asserts countRelationshipsTo(statusId) == 1 before soft delete. This is deliberately not the incident-task mirror path: those records are written asynchronously and best-effort by the incident workflow (fresh random record id, sync failures swallowed), so a test keyed on them could pass vacuously whenever the workflow does not fire. The direct creation is deterministic and asserts the exact edge the regression walks over.
  4. Run mvn spotless:apply on the touched modules, then commit. No .github/java-tests/impact-map.json change is needed: jdbi3/EntityRepository.java matches the existing core area glob jdbi3/Entity* (fullSuite), and TestCaseResourceIT matches *TestCase*IT in the data-quality area.

Verification

status: green · RED→GREEN re-verified on the follow-up commit's hardened tests
- [pass] RED: mvn -pl openmetadata-integration-tests test -Dtest='TestCaseResourceIT#test_testCaseSoftDeleteAndRestoreWithIncident_200_OK+test_testCaseCreateOrUpdateOnSoftDeletedWithIncident_200_OK'
  against a service build with the restoreChildren fix reverted — Tests run: 2, Errors: 2; both tests fail
  with the issue's 404 (ApiException (404): Unknown entity type 'testCaseResolutionStatus') at the restore
  and upsert calls, after the PARENT_OF pre-condition assertion passed — the deterministic setup
  reproduces the bug and cannot pass vacuously
- [pass] GREEN: same command against the fixed service — Tests run: 2, Failures: 0, Errors: 0
- [skipped] mvn spotless:check -pl openmetadata-service,openmetadata-integration-tests  (seen green after the last change)
- [pass] mvn -pl openmetadata-service test -Dtest=TestCaseResolutionStatusRepositoryTest -nsu

Review (sol): approve

  • [resolved] TestCaseResourceIT.java: the pre-condition now creates a resolution-status record directly and asserts the actual TestCase-to-resolution-status PARENT_OF edge (count == 1) instead of counting relationships to the incidentId, which previously counted the incident task's CREATED edges and could hold with no PARENT_OF child present.

Files

.../openmetadata/it/tests/TestCaseResourceIT.java  | 88 ++++++++++++
.../service/jdbi3/EntityRepository.java            | 10 ++-
2 files changed, 96 insertions(+), 2 deletions(-)

Closes #35826

Opened by taskr run 0142.

taskr run 0142.
`restoreChildren` now skips time-series children so soft-deleted test cases with incidents restore via both `/restore` and upsert; the two new integration tests failed before the fix and pass after it, and all planned checks pass.
@TeddyCr
TeddyCr marked this pull request as ready for review October 31, 2026 15:53
@TeddyCr
TeddyCr requested a review from a team as a code owner October 31, 2026 15:53
@TeddyCr
TeddyCr requested review from IceS2 and a balanced review from Copilot October 31, 2026 15:53
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

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.

@TeddyCr TeddyCr changed the title Restoring a soft-deleted TestCase that has incident history succeeds v Restoring a soft-deleted TestCase that has incident history succeeds Nov 2, 2026
…dition assert the actual PARENT_OF edge

The incident-task mirror records are written asynchronously and best-effort by
the incident workflow, and counting relationships to the incidentId counts the
task's CREATED edges — so the old guard could hold with no resolution-status
child present and the tests could pass vacuously. Create the resolution-status
record directly instead (record plus its PARENT_OF edge are written
synchronously in one transaction) and assert the edge count is exactly 1.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:52

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 added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Nov 2, 2026
@gitar-bot

gitar-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Skipping time-series children during subtree restoration changes restore behavior and could mishandle child types that require repository-based restoration.

Restoring a soft-deleted TestCase with incident history no longer fails with a 404, because restoreChildren now skips time-series children such as testCaseResolutionStatus, matching the existing bulk-path and delete-side filters. Regression tests cover both the restore endpoint and create-or-update on a soft-deleted case. No issues found.

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

@TeddyCr
TeddyCr added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-11-03T03:28:17Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Pages/AIProfile/ProfileTeam.spec.ts › Should confirm a team move in a popover, not a modal

@TeddyCr
TeddyCr merged commit 27fa0b5 into open-metadata:main Nov 3, 2026
68 of 73 checks passed
TeddyCr added a commit that referenced this pull request Nov 4, 2026
…he (#37086)

taskr run 0175.
PR #36754 is backported to the 2.0 worktree as staged changes (not committed); the RED/GREEN checks, the full TestCaseResourceIT class, and spotless all pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion 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.

Restoring a soft-deleted TestCase with incidents fails: "Entity repository for testCaseResolutionStatus not found"

3 participants