Skip to content

fix(s3): treat a 404 from a single-key delete as already deleted - #60

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
mwawacek:scout/s3-delete-missing-404-v2
Nov 9, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
mwawacek:scout/s3-delete-missing-404-v2

Conversation

@mwawacek

@mwawacek mwawacek commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

delete() is documented as "Deleting a missing key is not an error". On S3, DeleteObject answers 204 for a missing key. Google Cloud Storage's XML API, which S3Disk lists as a supported store (endpoint: 'https://storage.googleapis.com', batchDelete: false), answers 404 NoSuchKey instead. S3Disk turns that into a StorageServiceError, so on GCS:

await disk.delete('already-gone.txt'); // StorageServiceError: DeleteObject failed: NoSuchKey (404)
await disk.delete(['a.txt', 'missing.txt']); // same, with batchDelete: false

This affects every single-key delete, which always goes through DeleteObject, and every key when batchDelete is false.

Issue Number: N/A

What is the new behavior?

DeleteObject maps a 404 for the key to "not found" the same way get() and stat() do, and deleteObjects() ignores it, because the key is already gone. Other errors, NoSuchBucket included, still fail.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Google Cloud Storage answers DeleteObject for a key that doesn't exist
with 404 NoSuchKey, where S3 answers 204. delete() of a missing key,
which is documented not to be an error, failed there with a
StorageServiceError, for every single-key delete and for every key with
batchDelete: false.

A 404 for a missing key is now ignored; other errors, such as
NoSuchBucket, still fail.
@kamilmysliwiec
kamilmysliwiec merged commit 703b1a4 into nestjs:master Nov 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants