Repository navigation
fix(drive): add deleteStale endpoint and set File column FQNs on write - #31375
Conversation
Two defects that make Drive connectors (SFTP, GoogleDrive, SharePoint) unusable
in normal operation.
1. deleteStale was never exposed on the Drive resources, so every ingestion run
ended with three HTTP 405s and marked itself Failed even when extraction had
succeeded. markDeletedDirectories / markDeletedFiles were silently no-ops and
entities removed at the source stayed in the catalogue forever. The endpoint
is declared on Table, Topic, Container and five other resources; Directory,
File, Spreadsheet and Worksheet were missing it. The implementation is fully
generic in EntityResource.deleteStaleEntities and the service-scope resolution
already maps directory/file to driveService, so this only needed the four
endpoint declarations.
2. FileRepository set column FQNs when reading an entity back (setFields) but
never on the write path. The update path compares columns by FQN, so a second
ingestion of any file with columns failed with
Cannot invoke "String.equals(Object)" because the return value of
"Column.getFullyQualifiedName()" is null
leaving metadata frozen at whatever the first run captured. WorksheetRepository
already does this inside setFullyQualifiedName; FileRepository now matches,
guarded for the non-tabular files that have no columns.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 821 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 50m 59s ⏱️ Max setup 3m 11s · max shard execution 19m 1s · max shard-job elapsed before upload 22m 23s · reporting 7s 🌐 210.80 requests/attempt · 2.48 app boots/UI scenario · 26.29% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…olumns Follow the repo Java conventions: no fully-qualified class names in code (the new deleteStale blocks referenced org.openmetadata.schema.type.api.BulkOperationResult inline; TableResource imports it), and use CommonUtil.listOrEmpty for the columns guard instead of a null check, matching how ContainerRepository and TableRepository handle optional column lists.
Enabling deleteStale exposed a latent bug in the SFTP source: the FQNs it registers as "seen" during a run did not match the FQNs the create requests actually store, so stale-entity deletion removed entities that had just been ingested correctly. Two mismatches: - Files used the base register_record_file, which builds the FQN from a single context directory. For a file nested two levels deep that yields service.nested."f.csv" instead of service.data.nested."f.csv", and for a root-level file there is no context directory at all. Override it and pass the same path components the create request uses, with a direct _build for root-level files since fqn.build rejects an empty directory path. - register_record_directory already built the correct path-based FQN on its main branch; its docstring now records why the FQN has to match, so the fallback is not "simplified" back to the bare name later. These tests were passing before only because deleteStale returned 405 and no deletion ever happened - with deletion working, six SFTP integration tests covering nested directories and root-level files correctly began to fail.
…mpty SftpDirectoryInfo.path is optional. yield_directory and register_record_directory both fall back to `[directory_info.name]` when it is empty, but the file registration path did not - so a nested file whose directory carried no path components would register the root-level FQN and be deleted as stale straight after being ingested. Use the same fallback everywhere.
…new line TopologyContext attributes are populated dynamically, so basedpyright cannot see drive_service. The ten pre-existing accesses in this file are carried in the static-check baseline; a newly added line is not, and the baseline runs in discard mode, which fails on any new error. Suppress it inline the same way googledrive/connection.py does.
SourceAPIClient.delete wraps REST.delete, which gained a `json` parameter ahead of `headers` when deleteStale moved to the DELETE verb. The wrapper kept the old four-positional signature, so the override no longer matched the base. Mirror the new signature and pass `json` through. GoogleDriveSource.register_record_file reads context.drive_service, which TopologyContext populates dynamically. The pre-existing accesses are carried in the static-check baseline; a new line is not, and the baseline runs in discard mode. Suppress it inline the same way the SFTP source does.
|
Code Review ✅ Approved 3 resolved / 3 findingsAdds the missing deleteStale endpoint and fixes column FQN assignment on the write path for drive entities. Addressed the File FQN directory-name fallback, deleteStale request body on DELETE, and null stored FQN rename map key findings. ✅ 3 resolved✅ Edge Case: File FQN skips the directory-name fallback used elsewhere
✅ Edge Case: deleteStale relies on a request body carried on DELETE
✅ Edge Case: Null stored FQN can insert a null key into rename map
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
#31375) * fix(drive): add deleteStale endpoint and set File column FQNs on write Two defects that make Drive connectors (SFTP, GoogleDrive, SharePoint) unusable in normal operation. 1. deleteStale was never exposed on the Drive resources, so every ingestion run ended with three HTTP 405s and marked itself Failed even when extraction had succeeded. markDeletedDirectories / markDeletedFiles were silently no-ops and entities removed at the source stayed in the catalogue forever. The endpoint is declared on Table, Topic, Container and five other resources; Directory, File, Spreadsheet and Worksheet were missing it. The implementation is fully generic in EntityResource.deleteStaleEntities and the service-scope resolution already maps directory/file to driveService, so this only needed the four endpoint declarations. 2. FileRepository set column FQNs when reading an entity back (setFields) but never on the write path. The update path compares columns by FQN, so a second ingestion of any file with columns failed with Cannot invoke "String.equals(Object)" because the return value of "Column.getFullyQualifiedName()" is null leaving metadata frozen at whatever the first run captured. WorksheetRepository already does this inside setFullyQualifiedName; FileRepository now matches, guarded for the non-tabular files that have no columns. * refactor(drive): import BulkOperationResult and use listOrEmpty for columns Follow the repo Java conventions: no fully-qualified class names in code (the new deleteStale blocks referenced org.openmetadata.schema.type.api.BulkOperationResult inline; TableResource imports it), and use CommonUtil.listOrEmpty for the columns guard instead of a null check, matching how ContainerRepository and TableRepository handle optional column lists. * fix(sftp): record file and directory FQNs that match what is stored Enabling deleteStale exposed a latent bug in the SFTP source: the FQNs it registers as "seen" during a run did not match the FQNs the create requests actually store, so stale-entity deletion removed entities that had just been ingested correctly. Two mismatches: - Files used the base register_record_file, which builds the FQN from a single context directory. For a file nested two levels deep that yields service.nested."f.csv" instead of service.data.nested."f.csv", and for a root-level file there is no context directory at all. Override it and pass the same path components the create request uses, with a direct _build for root-level files since fqn.build rejects an empty directory path. - register_record_directory already built the correct path-based FQN on its main branch; its docstring now records why the FQN has to match, so the fallback is not "simplified" back to the bare name later. These tests were passing before only because deleteStale returned 405 and no deletion ever happened - with deletion working, six SFTP integration tests covering nested directories and root-level files correctly began to fail. * fix(sftp): fall back to the directory name when path components are empty SftpDirectoryInfo.path is optional. yield_directory and register_record_directory both fall back to `[directory_info.name]` when it is empty, but the file registration path did not - so a nested file whose directory carried no path components would register the root-level FQN and be deleted as stale straight after being ingested. Use the same fallback everywhere. * fix(sftp): suppress the known TopologyContext attribute error on the new line TopologyContext attributes are populated dynamically, so basedpyright cannot see drive_service. The ten pre-existing accesses in this file are carried in the static-check baseline; a newly added line is not, and the baseline runs in discard mode, which fails on any new error. Suppress it inline the same way googledrive/connection.py does. * refactor(api): deleteStale is a DELETE, not a PUT Review feedback on #31375. `deleteStale` deletes entities, so it belongs on the DELETE verb. Flipping only the four new Drive resources would leave them unreachable from the shared ingestion client (which sent PUT), so the verb moves on all 18 resources that declare the endpoint, plus both callers. The seen-FQN set stays in the request body — a scope can hold thousands of FQNs, which no query string can carry — so this is DELETE with an entity body. Jersey routes the literal `/deleteStale` ahead of `/{id}`, the same way the 48 existing literal-vs-template sibling routes already resolve. A server that predates the endpoint now falls into `deleteById`, whose UUID path param rejects "deleteStale" with a 404 — the status the client's legacy fallback already keys on, so old-server behaviour is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(drive): correct GoogleDrive file FQNs and tolerate legacy null column FQNs Two defects that only became visible once deleteStale started working. GoogleDrive registered every file under an FQN that never matches the stored one, so a working deleteStale soft-deletes all of them on the first run. `file_request.directory` holds the parent's *full* FQN, which already starts with the service name, but it was passed to fqn.build as a single path component - producing svc."svc.data"."f.csv" instead of svc.data."f.csv". The root-level branch was wrong too: it invented a "root" path segment, while those files are created with directory=None and stored directly under the service. Pass the path components below the service, and build the root-level FQN the same way the create request does. Same class of bug as the SFTP one fixed earlier in this branch; SharePoint has no connector implementation, so nothing to fix there. Columns persisted before their repository set column FQNs on the write path carry a null FQN, so re-ingesting a file created by an older version NPE'd in updateColumns. Compare with Objects.equals. The update itself repopulates the FQN, so those rows repair themselves on the next ingestion and no backfill migration is needed - the Drive entities have shipped since 1.11, so such rows do exist in the field. * fix(api): reject a null deleteStale body and skip null-FQN renames Addresses two review findings. Null stored column FQN inserted a null key into the rename map. The map is a from -> to for rewriting lineage edges that already exist, so a column being given an FQN for the first time has no prior edge to rewrite -- it is not a rename and does not belong in the map. Skipping it also keeps a null key out of what handleColumnLineageUpdates forwards to updateColumnLineage and updateColumnsInUpstreamLineage. The Objects.equals tolerance stays: it exists only so rows persisted before FileRepository set column FQNs on the write path repair themselves on the next run instead of NPE'ing. deleteStale carries its seen-FQN set in a DELETE body, which an aggressive proxy can strip. An empty seen-set was already safe -- bulkDeleteStaleEntities treats it as zero deletions rather than marking the whole scope stale -- and a body removed outright was already a 400, since Jackson cannot map a zero-length entity and JsonMappingExceptionMapper answers for it. The gap was the shape in between: a body that parses cleanly to null binds the parameter to null, @Valid on a null argument is a pass, the @NotNull constraints on the schema fields never run, and validateScopeRequest NPEs into a 500. Mark the parameter @NotNull so ConstraintViolationExceptionMapper answers 400 there too, and declare the body via @RequestBody(required = true) so the generated spec documents the endpoint as body-carrying. The failure modes stay distinguishable: any dropped body fails the run loudly with a client error, a genuinely empty seen-set warns and deletes nothing. The ingestion client needs no change -- delete_stale_entities keys its legacy fallback on 404 only, so a 400 propagates rather than silently re-hiding the problem. Applied to all 18 resources declaring the endpoint. BulkDeleteStaleIT covers both dropped-body shapes; the null-body test asserts on the constraint message so it cannot pass against the unfixed resource. BulkApi.deleteStaleRaw takes a body publisher to send them. * fix(ingestion): repair the two basedpyright errors from this branch SourceAPIClient.delete wraps REST.delete, which gained a `json` parameter ahead of `headers` when deleteStale moved to the DELETE verb. The wrapper kept the old four-positional signature, so the override no longer matched the base. Mirror the new signature and pass `json` through. GoogleDriveSource.register_record_file reads context.drive_service, which TopologyContext populates dynamically. The pre-existing accesses are carried in the static-check baseline; a new line is not, and the baseline runs in discard mode. Suppress it inline the same way the SFTP source does. --------- Co-authored-by: mohitdeuex <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Pablo Takara <[email protected]> Co-authored-by: IceS2 <[email protected]>



Fixes #31381
Two defects found while testing the SFTP connector for the 2.0 release. Both sit in the Drive entity
layer, so they affect GoogleDrive and SharePoint identically — not just SFTP.
1.
deleteStalewas never exposed on the Drive resourcesEvery ingestion run ended with three
HTTP 405 Method Not Allowed:PUT /v1/tables/deleteStalereturns 400 (route exists, body rejected) — 405 vs 400 is the tell. Theendpoint is declared on
TableResource,TopicResource,ContainerResourceand five others, but wasmissing from all four Drive resources.
Impact:
markDeletedDirectories/markDeletedFileswere silent no-ops — a file deleted at thesource stayed in the catalogue forever. It also made every run report Failed even when extraction
succeeded, so a real failure was indistinguishable from the permanent one.
Fix: declare the endpoint on
Directory,File,SpreadsheetandWorksheet. No new logic —EntityResource.deleteStaleEntitiesis fully generic, andresolveScopeEntityTypealready mapsdirectory/filetodriveServiceviaENTITY_SERVICE_TYPE_MAP.2.
FileRepositorynever set column FQNs on the write pathThe first ingestion of a service was clean; every run after it failed on each file with columns:
Observed 0 errors on run 1, then 17 and 18 on runs 2 and 3, reproduced on three separate services and
through the CLI.
Impact: metadata was frozen at whatever the first run captured — a column added at the source
could never reach OpenMetadata.
Cause:
setColumnFQNwas called insetFields(the read path) but not insetFullyQualifiedName(the write path), so columns were persisted with a null FQN and the updatecomparison NPE'd.
WorksheetRepositoryalready does this correctly insidesetFullyQualifiedName;FileRepositorynow matches, guarded with a null check because non-tabular files (images, PDFs,parquet) have no columns and
ColumnUtil.setColumnFQNdoes not accept null.Testing
Found against a live SFTP server on release-2-0, driving real ingestion through both a hybrid runner
and the CLI.
mvn compileandspotless:applyclean.Full test notes: 17 bugs found across phases 0–4; these are the two blockers that need server-side
changes. The connector's own remaining issues are being fixed separately.