Skip to content

GCP: Throw NotFoundException from GCSInputStream.readTail for missing blobs - #19063

Closed
linzch3 wants to merge 1 commit into
apache:mainfrom
linzch3:gcs-input-stream-missing-blob
Closed

linzch3 wants to merge 1 commit into
apache:mainfrom
linzch3:gcs-input-stream-missing-blob

Conversation

@linzch3

@linzch3 linzch3 commented Nov 20, 2026

Copy link
Copy Markdown

Follow-up to #19048, as @ebyhr pointed out in the review there.

Background

GCSInputStream.readTail() looks up the blob size with storage.get(blobId).getSize() when the length isn't known. Storage.get(BlobId) returns null for a missing object, so reading the tail of a deleted file throws an NPE instead of a NotFoundException. The channel reads already map 404s to NotFoundException via GCSExceptionUtil (#15734), but this lookup happens before any channel is opened.

Fix

If the blob is missing, throw NotFoundException("Location does not exist: %s", blobId.toGsUtilUri()), same message as GCSExceptionUtil. A known length still skips the lookup.

Tests

  • New TestGCSInputStream#readTailMissingBlob: readTail on a blob that doesn't exist (with LocalStorageHelper) throws NotFoundException with the location. It fails with the NPE when the fix is reverted.
  • ./gradlew :iceberg-gcp:test and :iceberg-gcp:spotlessCheck pass locally (JDK 21).

AI disclosure: I used an AI assistant (Claude Opus 5.5) to help write this change and the test. I reviewed the code and ran the tests myself.

@github-actions github-actions Bot added the GCP label Nov 20, 2026
@linzch3

linzch3 commented Nov 21, 2026

Copy link
Copy Markdown
Author

Closing this, the fix is now folded into #19048 per review discussion there.

@linzch3 linzch3 closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant