Repository navigation
Description
Detail Bug Report
Introduced in #34694 by @harshach on Oct 16, 2026
Summary
- Context: The
collectMetadataTaskautomated node in governance (lifecycle) workflows keeps one "Fill in missing metadata" task per asset and lifecycle stage in sync with the asset's actual metadata state. - Bug:
CollectMetadataImplresolves the workflow's related entity withInclude.NON_DELETED, so if the asset has been soft-deleted by the time the node runs, the entity lookup throwsEntityNotFoundExceptionand the node converts it into a workflow runtime error instead of handling the deleted asset gracefully. - Actual vs. expected: The stage is marked
FAILED, the workflow instance is markedEXCEPTION, and this repeats on every periodic-batch run for that asset — while every sibling automated-task node in the sameimpl/directory (CheckEntityAttributesImpl,SetEntityAttributeImpl,RollbackEntityImpl,SetEntityCertificationImpl,DataCompletenessImpl,CheckChangeDescriptionTaskImpl,SetGlossaryTermStatusImpl) resolves the same entity withInclude.ALL, and hard-deleted assets are handled by design via intentional workflow cancellation with the cause "Entity deleted". A deleted asset should be skipped (closing its stale stage tasks), not fail the stage. - Impact: For any asset that is soft-deleted while a lifecycle workflow targets it, the stage permanently errors out and its open "Fill in missing metadata" tasks are never closed, because the reconcile logic (
MetadataCollectionService.closeTasksOfOtherStages) never gets to run for that asset; on periodic-batch triggers the same asset is re-fetched from the search index and re-fails the stage on every cron run.
Code with Bug
openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/CollectMetadataImpl.java:
final var entity = variables.getRelatedEntity(link, "*", Include.NON_DELETED); // <-- BUG 🔴 throws EntityNotFoundException for a soft-deleted asset
...
} catch (RuntimeException failure) {
// Any failure collecting becomes the workflow's runtime error, so the stage's error boundary
// handles it; collect() declares no checked exceptions.
LOG.error("Metadata collection failed for {}", execution.getCurrentActivityId(), failure);
variables.setGlobalVariable(EXCEPTION_VARIABLE, failure.toString());
throw new BpmnError(WORKFLOW_RUNTIME_EXCEPTION, failure.getMessage()); // <-- BUG 🔴 deleted asset becomes stage failure; tasks never reconciled/closed
}Explanation
Include.NON_DELETEDintentionally excludes soft-deleted entities;EntityRepository.find(...)throws wheninclude == NON_DELETEDandentity.getDeleted() == true. This makes soft-deleted assets indistinguishable from missing assets during entity resolution.- Because
CollectMetadataImplcatches allRuntimeExceptionand rethrows aBpmnError(WORKFLOW_RUNTIME_EXCEPTION), the soft-delete case is treated as a workflow runtime failure (stageFAILED, instanceEXCEPTION) instead of being skipped. - For periodic-batch workflows, soft-deleted entities are deterministically re-selected on every run because the search index retains documents and flips
deleted=true(no defaultdeleted=falsefilter). This causes repeated failures for the same asset. - The failure happens before
MetadataCollectionService.reconcile(...), socloseTasksOfOtherStages(...)never runs; open "Fill in missing metadata" tasks tied to the deleted asset remain indefinitely.
Codebase Inconsistency
Sibling automated-task delegates in the same impl/ directory resolve the workflow target entity with Include.ALL (so they can detect deleted=true and handle it), e.g.:
// CheckEntityAttributesImpl.java
EntityInterface<?> entity = varHandler.getRelatedEntity(entityLink, "*", Include.ALL);Recommended Fix
Resolve the entity with Include.ALL and explicitly skip when entity.getDeleted() is true, while also closing the stage’s open metadata tasks (skipping without cleanup leaves stale tasks):
final var entity = variables.getRelatedEntity(link, "*", Include.ALL); // <-- FIX 🟢 match sibling convention
if (Boolean.TRUE.equals(entity.getDeleted())) {
LOG.info("Skipping metadata collection for soft-deleted entity {}", link);
closeTasksOfOtherStages(entity, currentTaskId); // <-- FIX 🟢 close stale stage tasks
return;
}History
This bug was introduced in commit 80b3ec5 ("Fixes #34693: support lifecycle gates, metadata tasks and metric intake", #34694, 2026-10-16). That commit created CollectMetadataImpl.java and used getRelatedEntity(link, "*", Include.NON_DELETED) from the start, causing soft-deleted targets to throw EntityNotFoundException and be converted into BpmnError(WORKFLOW_RUNTIME_EXCEPTION) failures.
Activity