Repository navigation
fix(lineage): keep an edge writable after its pipeline is deleted - #34816
Conversation
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.
❌ 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 |
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 OptionsDisplay: compact → Counting what did not apply, without listing it. 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 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 isPipelineLineage(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_lineageandadd_lineage_by_nameinlineage_mixin.py). The server then rejects it:patchLineageEdgeapplies the patch to the stored details, then re-validates the resulting pipeline withInclude.NON_DELETED. The patch never touches/pipeline, but it still returns 404pipeline instance for <id> not found.addLineagerejects 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 newresolveEdgePipeline(requested, stored)is used byaddLineage(against the prior edge details) andpatchLineageEdge(against the pre-patch details):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 onlyPipelineLineageedges, so aDbtLineageorQueryLineageedge can still point at a hard-deleted pipeline.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 withInclude.ALL.Why on the server and not in the ingestion client:
getLineageEdgereturns the reference exactly as stored when the edge was written, which saysdeleted: false.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:
Needs a backport to
2.0.Type of change:
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
sqlQuery). The edge keeps the pipeline.DbtLineageedge whose pipeline was hard-deleted accepts a PUT carrying that pipeline. The dangling reference is dropped.Unit tests
LineageRepository.javaoverall is at 72.0% of lines and 59.6% of branches. The misses are in code this PR doesn't touch.TimeoutExceptionand no server error:LineageResourceIT.testLineageGraphWithMultipleDepthsandLineagePipelineAnnotatorIT.serviceLineage_ReshapedEdgeShowsPipelineHopInSearch. Both pass when rerun without the agent.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.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.main, 3 of the 5 fail. The soft-delete PATCH and PUT return404 pipeline instance for <id> not found, and the hard-delete PUT returns404 Entity not found: pipeline <id>. The 2 rejection tests pass on both. All 5 pass with the fix.LineageResourceIT,LineagePipelineAnnotatorIT,ServiceLineageRefcountIT,ServiceLineagePipelineRoutingMigrationIT,LineageManualEdgeITand the new IT ran 92 tests with 0 failures. The 3 skipped tests are@Disabledonmain.mvn spotless:applyrun on both modules.Ingestion integration tests
Playwright (UI) tests
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:
/v1/lineage/table/name/{from}/table/name/{to}with a pipeline.[{"op":"add","path":"/sqlQuery",...}], then PUT it again with the same pipeline.GET /v1/lineage/getLineageEdge/...shows the SQL with the pipeline still referenced.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>. The title uses thefix(lineage): …form instead, because the issue is in the collate repo.Fixes …above (fullowner/repo#form).