Repository navigation
Fixes 36025: Close lifecycle metadata tasks of a soft-deleted asset instead of failing the stage - #37623
Conversation
…eleted asset instead of failing the stage
CollectMetadataImpl loads the asset with Include.ALL like its sibling nodes.
A soft-deleted asset cancels every open Metadata Completion task for that
asset ("The asset was deleted") and the node completes normally instead of
throwing a BpmnError on every run. Re-check on such a task completes it
instead of returning 404. Restoring the asset reopens the same deterministic
task on the next run. The lifecycle metadata-task ADR gains a v2 revision.
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Why these tests
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=CollectMetadataTaskTest,MetadataCollectionServiceTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=LifecycleMetadataTasksIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
❌ PR checklist incompleteThis 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 |
Open Metadata Completion tasks are listed by their about FQN, which a domain and a classification can share. The three closes in MetadataCollectionService now keep only the tasks whose about id is the asset's, so deleting a classification no longer cancels the open task of a live domain with the same name. The deleted-asset log line is written only when there is something to cancel, the IT follows the change-event pages, and the ADR amendment is narrowed to the collect node, naming the move node as a follow-up.
Code Review ✅ Approved 🟡 Medium riskChanging lifecycle handling closes metadata tasks for soft-deleted assets and completes Re-checks, which could alter workflow outcomes for affected assets. Fixes the lifecycle collect node so a soft-deleted asset no longer fails the stage: it loads the asset with 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 #36025
CollectMetadataImplloaded the lifecycle's target asset withInclude.NON_DELETED. For a soft-deleted asset that throwsEntityNotFoundException, which becameBpmnError(WORKFLOW_RUNTIME_EXCEPTION): the stage was FAILED and the instance EXCEPTION. Periodic batches re-select the deleted asset, so it failed on every run. Because the failure came beforeMetadataCollectionService.reconcile, the asset's open "Fill in missing metadata" and "Revise and resubmit" tasks were never closed. Re-check on one of those tasks returned 404.Now the collect node loads the asset with
Include.ALL, as every sibling node inautomatedTask/impl/does. When the asset is soft-deleted, the node cancels every open Metadata Completion task for that asset with "The asset was deleted" and completes normally. Re-check on such a task completes it. Restoring the asset reopens the same deterministic task, with its history, on the next run. Hard delete keeps its existing cancellation path.The suggested
closeTasksOfOtherStages(entity, currentTaskId)call skips the current task and only closes stages the asset has left, so the current stage's task would stay open. This PR adds a dedicated close instead.Type of change:
High-level design:
CollectMetadataImpl.collectloads the asset withInclude.ALL. For a deleted asset it callscloseTasksOfDeletedAssetand returns beforereconcile/revise, so the REQUEST and RESUBMIT configurations skip the same way. Thegovernance-botlookup stays onNON_DELETED.MetadataCollectionService.closeTasksOfDeletedAssetlists the asset's open Metadata Completion tasks of every stage and workflow, both collection and revision tasks. It reuses the existingMAX_STALE_TASKS = 50bound and cancels each one with the newASSET_DELETEDcomment. More than 50 tasks converge over later runs.aboutnames by id.listOpenTasksByEntityAndTypematches on the about-FQN hash only, and domains, glossaries, classifications and data products all have name-only FQNs. So every close inMetadataCollectionServicegoes throughopenTasksOf(entity), which keeps only tasks about this asset's id:closeTasksOfDeletedAsset, and also the existingcloseTasksOfOtherStagesandcloseRevisionsOutside. Otherwise deleting classification "Finance" would cancel a live domain "Finance"'s task. The 50-task cap still applies before this filter.requireFilledInloads the asset withInclude.ALL. A deleted asset asks for nothing (isAskedFor), so Re-check completes the task.TaskRepository.resolveTaskdoesn't throw for an already-closed task, so a lost race can't become aBpmnError, and no try/catch was added. The losing server writes one more version over the close instead of skipping it. Making that a true no-op would need a status-guarded write inresolveTask, which every caller shares, so it is left out of this PR.resolveTaskalready loadsaboutwithInclude.ALL, so resolving a task whose asset is soft-deleted needs no change. The onlyNON_DELETEDlookup on that path is domain inheritance inprepare(). It is caught and logs one WARN, and the stored domains are kept.docs/decisions/2026-10-15-a-lifecycle-stage-asks-for-its-missing-metadata-in-one-task.mdrecords the collect node's deleted-asset rule, Re-check on a deleted asset, and the rule that a task belongs to the asset itsaboutnames by id.SetEntityAttributeImpl→EntityRepository.patch) still loads only live assets, so it can fail on a deleted asset.Tests:
Use cases covered
aboutasset is soft-deleted stores its change event.Unit tests
MetadataCollectionServiceTest: 13/13 passed, including the new cases forcloseTasksOfDeletedAssetand the deleted-asset Re-check. Its fixtures carry anabout, and the deleted-asset and stage-move cases include a same-FQN task about another asset that must not be resolved.CollectMetadataTaskTest: 2/2 passed.closeTasksOfDeletedAssetandASSET_DELETEDdon't exist).static-code-analysisprofile. The planner flagsCollectMetadataImplas having no unit test. It is a Flowable delegate, andLifecycleMetadataTasksITruns it through a real Flowable process.Backend integration tests
LifecycleMetadataTasksIT, withdeletingTheAssetCancelsItsTasksAndRestoringItReopensThem,aRecheckCompletesTheTaskOfADeletedAssetanddeletingAnAssetLeavesTheTasksOfAnotherAssetWithItsNameOpen.hasUpdateEventnow followspaging.after, so concurrent ITs can't push the event off the first page.metadataTasks_<short prefix>, because the longer name overflowed a Flowable id column.expected: <FINISHED> but was: <EXCEPTION>, withEntityNotFoundException: classification instance … not foundin the server log.ApiException (404).1cb741df8c:expected: <Open> but was: <Cancelled>. The server log shows "cancelling its 2 open tasks", this asset's task and the domain's.492242b0ae): 11/11 passed on MySQL + Elasticsearch, parallel lane.--scope full, not run locally):ChangeRequest*IT,DataContractValidationAppITandWorkflowDefinitionResourceIT.RdfGovernanceRulesITandSearchAccessRulesIT.Local Java test run: PASSED
1cb741df8cc5(baseorigin/main). The run had the uncommitted changes that are now commit492242b0ae.--scope full).Ingestion integration tests
Not applicable, no ingestion changes.
Playwright (UI) tests
Not applicable, no UI changes.
Manual testing performed
The IT drives the real REST API and a real Flowable process against MySQL and Elasticsearch. It opens a lifecycle metadata task, soft-deletes the asset, runs the workflow and reads back the task status, comment, version and run status. It then restores the asset and runs again, and calls Re-check on a deleted asset's task.
UI screen recording:
Not applicable, backend-only 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 change.
For a UI feature or feature task: not applicable, no UI change.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: a fresh-context review of
1cb741df8cagainstREVIEW.mdfound one 🔴, fixed in492242b0ae: closing by FQN could cancel a live same-named asset's task. Tasks are now filtered byaboutid, with an IT and unit cases.Nits fixed: the IT event paging, the INFO log only when there is something to cancel, and the ADR narrowed to the collect node. Nits answered above: the move node and restore of revision tasks are follow-ups, and the concurrent double close is left as described in the design section.
Decision check: the deleted-asset rule is a v2 revision of the lifecycle metadata-task ADR linked above.
Bug fix: I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code