Repository navigation
Conversation
…et entity context
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Impacted, not run locally (2)
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=LineageResourceDeleteByTypeAuthorizationTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=LineageDeleteByTypeAuthorizationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
❌ 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 🔴 High riskBinding deleteLineageByType to target-entity authorization changes access decisions; without it, callers could delete lineage outside their permitted domain or tag scope. Authorizes VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. 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 #39150
I updated
DELETE /v1/lineage/{entityType}/{entityId}/type/{lineageSource}(LineageResource#deleteLineageByType) to authorize against the real target entity'sResourceContext(Entity.getEntityReferenceById(entityType, entityId, Include.ALL)+OperationContext(entityType, MetadataOperation.EDIT_LINEAGE)), matching its FQN-based siblingdeleteLineageByTypeAndName. Previously,deleteLineageByTypeauthorized with a dummyLineageResourceContextwhosegetResource()returned"lineage"and whosegetDomains(),getTags(),getOwners(), andgetEntity()all returnednull, allowing callers with conditional policies (hasDomain(),noOwner(), ormatchAnyTag(...)DENY) to bypass authorization and bulk-delete lineage on entities outside their scope.openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java: AddedauthorizeLineageReference(SecurityContext, String entityType, UUID entityId, Include)mirroring the existing FQN overload, routeddeleteLineageByTypethrough it withInclude.ALL, and removed the now-dead package-privateLINEAGE_FIELDconstant andLineageResourceContextinner class.openmetadata-service/src/test/java/org/openmetadata/service/resources/lineage/LineageResourceDeleteByTypeAuthorizationTest.java: Added unit tests verifyingtableandpipelinetargetResourceContextbinding (including entity ID resolution via the targetEntityRepository),EDIT_LINEAGEoperation propagation, fail-closedAuthorizationExceptionpreventing DAO delete, and 404EntityNotFoundExceptionskipping authorization and delete.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/LineageDeleteByTypeAuthorizationIT.java: Added 6 real HTTP integration tests exercisinghasDomain()deny on another domain,hasDomain()allow on the caller's own domain (with atable-scoped rule),matchAnyTag('PII.Sensitive')DENY,noOwner()deny on an owned table, 404 on a non-existent entity ID, and 404 on a mismatched(entityType, entityId).(Note for maintainers: as an external contributor I cannot add #39150 to the
Shippingproject board.)Type of change:
High-level design:
N/A — small bug fix bringing
deleteLineageByTypeinto parity withdeleteLineageByTypeAndName.Alternatives considered:
new ResourceContext<>(entityType, entityId, null)without first callingEntity.getEntityReferenceByIdwas rejected becauseResourceContext#resolveEntity()swallowsEntityNotFoundExceptionand leavesentity = null(causinghasDomain()/noOwner()to fail open astrueand allowing mismatched(entityType, entityId)pairs to reachCoreRelationshipDAOs#deleteLineageBySourcePipeline, whose SQL does not filter ontoEntity).(entityType, entityId)aligns with the existing@ApiResponse(404)contract ondeleteLineageByTypeand the exact behavior ofdeleteLineageByTypeAndName.Tests:
Use cases covered
All-scopedEDIT_LINEAGEpolicy conditioned onhasDomain()receives403 Forbiddenwhen callingDELETE /v1/lineage/table/{id}/type/ViewLineageon a table in another domain, and the lineage edge remains intact.table-scopedEDIT_LINEAGEpolicy conditioned onhasDomain()succeeds (200 OK) for a table in their own domain and deletes theViewLineageedge.All-scopedALLOW+matchAnyTag('PII.Sensitive')DENYreceives403 Forbiddenon aPII.Sensitive-tagged table, and the lineage edge remains intact.All-scopednoOwner()condition receives403 Forbiddenon an owned table, and the lineage edge remains intact.(entityType, entityId)pairs return404 Not Foundbefore callingdeleteLineageBySource.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/resources/lineage/LineageResourceDeleteByTypeAuthorizationTest.javaLineageResourceDeleteByTypeAuthorizationTest(plus 10 passed, 0 failed inLineageResourceGetLineageEdgeAuthorizationTestduring development). Every changed line inLineageResource#authorizeLineageReference(SecurityContext, String, UUID, Include)andLineageResource#deleteLineageByTypeis exercised byLineageResourceDeleteByTypeAuthorizationTest.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/LineageDeleteByTypeAuthorizationIT.javatarget/java-tests/local-pr-results-details.md.Local Java test run: PASSED
6e919ab81c94(baseorigin/main)--scope full).Ingestion integration tests
Playwright (UI) tests
Manual testing performed
make java_affected_run ARGS="--scope focused"against a real Testcontainers stack (mysql:8.4.13+elasticsearch:9.3.0+ full OpenMetadata Dropwizard application).LineageDeleteByTypeAuthorizationIT) end-to-end, confirming 403/404 denials leave lineage edges intact and 200 domain-matched delete removes the edge.mvn -B spotless:apply, pre-commit hooks (Google Java Code Style for Java,Decision records), andpython3 .github/scripts/plan_local_java_tests.py --check-branchall pass cleanly.UI screen recording:
Not applicable — Java backend authorization bug fix with no UI changes.
Checklist:
I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.
My PR title is
Fixes #39150: Authorize deleteLineageByType against target entity contextMy PR is linked to a GitHub issue via
Fixes #39150above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: N/A — no JSON Schema changes.
For a UI feature or feature task: N/A — Java backend authorization bug fix with no UI changes.
I have added tests (unit + backend integration tests) and listed them above.
Self-review: Reviewed commit
6e919ab81c94694410db47949bf5aa8dcf722047againstREVIEW.mdand.claude/rules/java.mdwith fresh eyes — 0 🔴 findings.DELETE /v1/lineage/{entityType}/{entityId}/type/{lineageSource}(called by Python ingestionoverrideLineageviaometa/mixins/lineage_mixin.py:delete_lineage_by_sourceand direct REST callers; no UI, Java SDK, or MCP callers exist in OSS). Removing package-privateLineageResource.LINEAGE_FIELDandLineageResourceContexthas zero callers in OSS; privateopenmetadata-collatewas not on disk to verify, though package-private nested resource types are not part of the public SPI.Entity.getEntityReferenceById(..., Include.ALL)and evaluatingResourceContextadds one cached reference lookup per call (plus one lazy repository read only when a non-admin caller has conditional policies — unconditional Allow-All ingestion bots never triggerResourceContext.resolveEntity()) and returns 404 instead of a no-op 200 for missing or type-mismatched IDs, matching siblingdeleteLineageByTypeAndNameand the existing 404 OpenAPI contract while closing the conditional-RBAC bypass.Decision check: No Accepted ADR is contradicted (verified
ADR:2026-11-20-a-method-returns-once,ADR:2026-11-03-lineage-edge-pipeline-is-restricted-and-view-authorized,ADR:2026-11-02-domain-only-access-cannot-change-administration-resources-in-no-domain;check_decision_records.pyis clean), and no new ADR is needed because this is a self-evident bug fix bringingdeleteLineageByTypeinto parity with siblingdeleteLineageByTypeAndNameand existing per-entity lineage authorization.I have added a test that covers the exact scenario we are fixing (
#39150referenced inLineageDeleteByTypeAuthorizationIT).