Skip to content

Fixes 36025: Close lifecycle metadata tasks of a soft-deleted asset instead of failing the stage - #37623

Merged
yan-3005 merged 4 commits into
open-metadata:mainfrom
Vamsi-klu:fix/36025-deleted-asset-lifecycle
Dec 2, 2026
Merged

yan-3005 merged 4 commits into
open-metadata:mainfrom
Vamsi-klu:fix/36025-deleted-asset-lifecycle

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36025

CollectMetadataImpl loaded the lifecycle's target asset with Include.NON_DELETED. For a soft-deleted asset that throws EntityNotFoundException, which became BpmnError(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 before MetadataCollectionService.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 in automatedTask/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:

  • Bug fix

High-level design:

  • CollectMetadataImpl.collect loads the asset with Include.ALL. For a deleted asset it calls closeTasksOfDeletedAsset and returns before reconcile/revise, so the REQUEST and RESUBMIT configurations skip the same way. The governance-bot lookup stays on NON_DELETED.
  • MetadataCollectionService.closeTasksOfDeletedAsset lists the asset's open Metadata Completion tasks of every stage and workflow, both collection and revision tasks. It reuses the existing MAX_STALE_TASKS = 50 bound and cancels each one with the new ASSET_DELETED comment. More than 50 tasks converge over later runs.
  • A task belongs to the asset its about names by id. listOpenTasksByEntityAndType matches on the about-FQN hash only, and domains, glossaries, classifications and data products all have name-only FQNs. So every close in MetadataCollectionService goes through openTasksOf(entity), which keeps only tasks about this asset's id: closeTasksOfDeletedAsset, and also the existing closeTasksOfOtherStages and closeRevisionsOutside. Otherwise deleting classification "Finance" would cancel a live domain "Finance"'s task. The 50-task cap still applies before this filter.
  • requireFilledIn loads the asset with Include.ALL. A deleted asset asks for nothing (isAskedFor), so Re-check completes the task.
  • Concurrent close: TaskRepository.resolveTask doesn't throw for an already-closed task, so a lost race can't become a BpmnError, 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 in resolveTask, which every caller shares, so it is left out of this PR.
  • resolveTask already loads about with Include.ALL, so resolving a task whose asset is soft-deleted needs no change. The only NON_DELETED lookup on that path is domain inheritance in prepare(). It is caught and logs one WARN, and the stored domains are kept.
  • ADR: a v2 revision of docs/decisions/2026-10-15-a-lifecycle-stage-asks-for-its-missing-metadata-in-one-task.md records the collect node's deleted-asset rule, Re-check on a deleted asset, and the rule that a task belongs to the asset its about names by id.
  • Known follow-ups, out of scope:
    • A stage's move node (SetEntityAttributeImpl → EntityRepository.patch) still loads only live assets, so it can fail on a deleted asset.
    • A Revise-and-resubmit task cancelled while the asset was deleted reopens only on a new rejection, not on restore.
  • Rollout: no schema, migration or UI change. After an upgrade, the next run of an affected lifecycle cancels the stuck tasks of soft-deleted assets and stops failing. Instances already in EXCEPTION stay in history.
  • Event-based lifecycles: soft delete doesn't start the workflow, so those tasks close on Re-check or on the next periodic run. That is documented in the ADR; no new delete-event hook is added.

Tests:

Use cases covered

  • A soft-deleted asset with an open collection task: the task is Cancelled with "The asset was deleted", and the run finishes instead of ending in EXCEPTION.
  • Running again on the deleted asset is a no-op that leaves the task version unchanged.
  • Deleting a classification leaves the open task of a live domain with the same name Open.
  • Restoring the asset and running again reopens the same task id with the missing fields.
  • Re-check on a deleted asset's task returns 200 and completes it (404 before).
  • Resolving a task whose about asset is soft-deleted stores its change event.
  • Unit level: a Revise-and-resubmit task and open tasks in several stages are all cancelled; with no open tasks it is a no-op; a deleted asset asks for nothing.

Unit tests

  • MetadataCollectionServiceTest: 13/13 passed, including the new cases for closeTasksOfDeletedAsset and the deleted-asset Re-check. Its fixtures carry an about, 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.
  • Before the fix, the new unit tests fail to compile (closeTasksOfDeletedAsset and ASSET_DELETED don't exist).
  • Line coverage was not measured: JaCoCo runs only under the static-code-analysis profile. The planner flags CollectMetadataImpl as having no unit test. It is a Flowable delegate, and LifecycleMetadataTasksIT runs it through a real Flowable process.

Backend integration tests

  • Updated: LifecycleMetadataTasksIT, with deletingTheAssetCancelsItsTasksAndRestoringItReopensThem, aRecheckCompletesTheTaskOfADeletedAsset and deletingAnAssetLeavesTheTasksOfAnotherAssetWithItsNameOpen. hasUpdateEvent now follows paging.after, so concurrent ITs can't push the event off the first page.
    • The test asset is a classification, because domains can't be soft-deleted.
    • Soft delete and restore don't start event-based workflows, so the test starts the existing noOp trigger directly and reads the run's status.
    • The workflow name is now metadataTasks_<short prefix>, because the longer name overflowed a Flowable id column.
  • Before the fix: 10 run, 1 failure, 1 error; the 8 existing tests passed.
    • expected: <FINISHED> but was: <EXCEPTION>, with EntityNotFoundException: classification instance … not found in the server log.
    • The Re-check gets ApiException (404).
  • The same-name test added after review fails on 1cb741df8c: expected: <Open> but was: <Cancelled>. The server log shows "cancelling its 2 open tasks", this asset's task and the domain's.
  • After the fix (492242b0ae): 11/11 passed on MySQL + Elasticsearch, parallel lane.
  • The RED run came before one later test-only change: a per-request cache clear between runs inside the test thread. The failing assertion comes before that point.
  • Pending (--scope full, not run locally):
    • 40 parallel-lane ITs.
    • The global-state lane: ChangeRequest*IT, DataContractValidationAppIT and WorkflowDefinitionResourceIT.
    • RdfGovernanceRulesIT and SearchAccessRulesIT.
    • The PostgreSQL + OpenSearch engine.

Local Java test run: PASSED

  • Commit: 1cb741df8cc5 (base origin/main). The run had the uncommitted changes that are now commit 492242b0ae.
  • Finished: 2026-11-12 06:34 UTC · 5.7 min
  • Scope: focused; merge readiness is not established. Broader steps deferred: 4 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (2 classes) 2 15 0 0 1.8 passed
integration mysql-elasticsearch · parallel 1 11 0 0 3.9 passed

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 1cb741df8c against REVIEW.md found one 🔴, fixed in 492242b0ae: closing by FQN could cancel a live same-named asset's task. Tasks are now filtered by about id, 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

…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.
@Vamsi-klu
Vamsi-klu requested a review from a team as a code owner November 12, 2026 06:12
@Vamsi-klu

Vamsi-klu commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Local Java test run: PASSED — details

  • Commit: 1cb741df8cc5 (base origin/main) — uncommitted changes were present
  • The summary is in the PR description.

Tests run locally

  • unit · openmetadata-service (2 classes): CollectMetadataTaskTest (2 passed), MetadataCollectionServiceTest (13 passed)
  • integration · mysql-elasticsearch · parallel: LifecycleMetadataTasksIT (11 passed)

Broader coverage not executed by this focused run

  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<40 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=ChangeRequestAdmissionIT,ChangeRequestApplyIT,ChangeRequestDecisionIT,ChangeRequestImportAndBulkIT,ChangeRequestLifecycleIT,ChangeRequestResourceIT,DataContractValidationAppIT,WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf -Dit.test=RdfGovernanceRulesIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingest -Dit.test=SearchAccessRulesIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Why these tests
  • added by author: Soft-deleted asset closes its lifecycle metadata tasks ← CollectMetadataTaskTest, LifecycleMetadataTasksIT, MetadataCollectionServiceTest
Commands
mvn -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

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

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.
@sonika-shah sonika-shah added the safe to test Add this label to run secure Github workflows on PRs label Dec 1, 2026
@gitar-bot

gitar-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Changing 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 Include.ALL, cancels its open Metadata Completion tasks with "The asset was deleted", and completes normally. 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

@yan-3005
yan-3005 merged commit 3f85ddd into open-metadata:main Dec 2, 2026
17 of 18 checks passed
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] Governance: lifecycle metadata-collection stage fails repeatedly when target asset is soft-deleted

4 participants