Skip to content

[Detail Bug] Governance: lifecycle metadata-collection stage fails repeatedly when target asset is soft-deleted #36025

Done

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_3377c26d-da48-4ccd-b83a-22c542f4fe83/bugs/bug_4311c269-284f-46ec-be23-ed87820fd36f

Introduced in #34694 by @harshach on Oct 16, 2026

Summary

  • Context: The collectMetadataTask automated 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: CollectMetadataImpl resolves the workflow's related entity with Include.NON_DELETED, so if the asset has been soft-deleted by the time the node runs, the entity lookup throws EntityNotFoundException and 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 marked EXCEPTION, and this repeats on every periodic-batch run for that asset — while every sibling automated-task node in the same impl/ directory (CheckEntityAttributesImpl, SetEntityAttributeImpl, RollbackEntityImpl, SetEntityCertificationImpl, DataCompletenessImpl, CheckChangeDescriptionTaskImpl, SetGlossaryTermStatusImpl) resolves the same entity with Include.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_DELETED intentionally excludes soft-deleted entities; EntityRepository.find(...) throws when include == NON_DELETED and entity.getDeleted() == true. This makes soft-deleted assets indistinguishable from missing assets during entity resolution.
  • Because CollectMetadataImpl catches all RuntimeException and rethrows a BpmnError(WORKFLOW_RUNTIME_EXCEPTION), the soft-delete case is treated as a workflow runtime failure (stage FAILED, instance EXCEPTION) 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 default deleted=false filter). This causes repeated failures for the same asset.
  • The failure happens before MetadataCollectionService.reconcile(...), so closeTasksOfOtherStages(...) 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

  1. added a commit that references this issue on Dec 2, 2026
    3f85ddd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions