Skip to content

fix(lineage): keep an edge writable after its pipeline is deleted - #34816

Merged
harshsoni2024 merged 2 commits into
mainfrom
fix/lineage-edge-deleted-pipeline
Oct 9, 2026
Merged

harshsoni2024 merged 2 commits into
mainfrom
fix/lineage-edge-deleted-pipeline

Conversation

@harshsoni2024

@harshsoni2024 harshsoni2024 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#7161

Once the pipeline on a lineage edge is soft-deleted, every later write to that edge fails with a 404, and nothing is saved.

A pipeline connector writes a table → table edge with its pipeline attached (source: PipelineLineage). When the job behind that pipeline is removed, the next run soft-deletes the pipeline. Soft delete leaves the edge and its pipeline reference in place. Only a hard delete cleans up edges, and only those whose source is PipelineLineage (PipelineRepository.entitySpecificCleanup).

Other writers keep sending lineage for the same table pair without a pipeline, for example SQL-parsed or query-log lineage. With check_patch=True, the ingestion client reads the stored edge and copies its pipeline onto the write, so the write doesn't strip the pipeline (add_lineage and add_lineage_by_name in lineage_mixin.py). The server then rejects it:

  • patchLineageEdge applies the patch to the stored details, then re-validates the resulting pipeline with Include.NON_DELETED. The patch never touches /pipeline, but it still returns 404 pipeline instance for <id> not found.
  • The client falls back to PUT with the same pipeline, and addLineage rejects it the same way.

Nothing is written, so every run repeats the failure and reports one error per affected edge. This was reported on 2.0.4 against a dbt Cloud service, where a removed job left one edge stuck this way.

The fix is in LineageRepository. A new resolveEdgePipeline(requested, stored) is used by addLineage (against the prior edge details) and patchLineageEdge (against the pre-patch details):

  • Same pipeline ID the edge already stores: resolved with Include.ALL, so a soft-deleted pipeline is kept. If it no longer exists at all, it's dropped from the edge instead of failing the write. That case happens because hard delete removes only PipelineLineage edges, so a DbtLineage or QueryLineage edge can still point at a hard-deleted pipeline.
  • Pipeline added or changed: still Include.NON_DELETED. Linking a deleted pipeline to an edge is still rejected with 404.

The rest of the write path already accepts a deleted pipeline. Search indexing (getPipelineOrStoredProcedure) and service-lineage hops (resolveAnnotatorPipelineService) both resolve it with Include.ALL.

Why on the server and not in the ingestion client:

  • The client can't tell the pipeline is deleted. getLineageEdge returns the reference exactly as stored when the edge was written, which says deleted: false.
  • The rejection hits any caller that writes to the edge without changing its pipeline, not only ingestion.

No ingestion change is needed. The client's existing copy-forward now succeeds. A soft-deleted pipeline stays referenced on the edge, consistent with soft delete keeping relationships so that a restore works.

Found while here, not changed in this PR:

  • The dbt Cloud connector attaches the job's pipeline only to edges whose parent model was built in the same job run. Its SQL-parsed edges across jobs carry no pipeline, which is why the live job never replaced the dead reference.

Needs a backport to 2.0.

Type of change:

  • Bug fix

High-level design:

N/A, small change (2 files): one helper in LineageRepository, shared by both write paths, plus an integration test.

Tests:

Use cases covered

  • An edge whose pipeline was soft-deleted accepts a PATCH that doesn't touch the pipeline (it adds sqlQuery). The edge keeps the pipeline.
  • The same edge accepts a PUT carrying that same pipeline, which is the client's fallback. The SQL lands and the pipeline is kept.
  • A DbtLineage edge whose pipeline was hard-deleted accepts a PUT carrying that pipeline. The dangling reference is dropped.
  • Linking a soft-deleted pipeline to a new edge is still rejected with 404.
  • Switching an edge from a live pipeline to a soft-deleted one is still rejected with 404.

Unit tests

  • No unit tests. The behaviour depends on soft vs hard delete in a real database, so it's covered by the integration test below.
  • Coverage: measured with the JaCoCo agent attached to the integration-test JVM, which runs the server in-process, across the six lineage suites listed below. All 15 executable changed lines and all 8 changed branches are covered. LineageRepository.java overall is at 72.0% of lines and 59.6% of branches. The misses are in code this PR doesn't touch.
  • In the instrumented run, two add-lineage calls timed out once with a client-side TimeoutException and no server error: LineageResourceIT.testLineageGraphWithMultipleDepths and LineagePipelineAnnotatorIT.serviceLineage_ReshapedEdgeShowsPipelineHopInSearch. Both pass when rerun without the agent.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • Files:
    • openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/LineageDeletedPipelineIT.java (new, 5 tests). The tests call the by-name PUT and PATCH routes that the ingestion client uses for SQL-parsed lineage.
  • RED/GREEN: on main, 3 of the 5 fail. The soft-delete PATCH and PUT return 404 pipeline instance for <id> not found, and the hard-delete PUT returns 404 Entity not found: pipeline <id>. The 2 rejection tests pass on both. All 5 pass with the fix.
  • Regression: LineageResourceIT, LineagePipelineAnnotatorIT, ServiceLineageRefcountIT, ServiceLineagePipelineRoutingMigrationIT, LineageManualEdgeIT and the new IT ran 92 tests with 0 failures. The 3 skipped tests are @Disabled on main.
  • mvn spotless:apply run on both modules.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

No separate manual run. The integration test sends the ingestion client's requests to a real server backed by MySQL and Elasticsearch:

  1. PUT /v1/lineage/table/name/{from}/table/name/{to} with a pipeline.
  2. Soft-delete the pipeline.
  3. PATCH the edge with [{"op":"add","path":"/sqlQuery",...}], then PUT it again with the same pipeline.
  4. Before the fix, both calls return 404. After the fix, both return 200, and GET /v1/lineage/getLineageEdge/... shows the SQL with the pipeline still referenced.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>. The title uses the fix(lineage): … form instead, because the issue is in the collate repo.
  • My PR is linked to a GitHub issue via Fixes … above (full owner/repo# form).
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable, no schema changes.
  • For UI changes: not applicable, no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Ingestion copies an edge's stored pipeline onto every lineage write that
carries none (SQL-parsed and query-log lineage), so those writes do not
strip the pipeline a pipeline connector attached. addLineage and
patchLineageEdge re-validated that pipeline with Include.NON_DELETED on
every write. Once the pipeline was soft-deleted, for example because its
dbt Cloud job was removed, every later write to the edge failed with
"pipeline instance for <id> not found", nothing was saved, and the agent
logged the same 404 on every run.

Only a pipeline newly linked to an edge now has to exist and not be
deleted. A pipeline the edge already references is kept when it was
soft-deleted, and dropped when it was hard-deleted, since hard delete
removes only PipelineLineage edges and other edges can still reference it.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 07:28
@harshsoni2024
harshsoni2024 requested a review from a team as a code owner October 7, 2026 07:28

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 reached their quota limit.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 7, 2026
Copilot AI balanced review requested due to automatic review settings October 8, 2026 05:37

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 reached their quota limit.

@gitar-bot

gitar-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Lineage writes now retain existing soft-deleted pipeline references, which could preserve outdated pipeline attribution on updated edges.

Fixes lineage edge writes failing with 404 after their pipeline is soft-deleted by adding resolveEdgePipeline() to LineageRepository. The helper keeps soft-deleted pipelines on edges for PATCH and PUT operations that don't change the pipeline, while still rejecting attempts to link deleted pipelines to new edges. Integration tests cover soft-delete preservation, hard-delete cleanup, and rejection cases with all tests passing.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@harshsoni2024
harshsoni2024 added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 5620522 Oct 9, 2026
160 of 161 checks passed
@harshsoni2024
harshsoni2024 deleted the fix/lineage-edge-deleted-pipeline branch October 9, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

3 participants