Skip to content

fix(bb-file-bucket): return 404 from local file server for delete-marked keys - #1167

Merged
xyos merged 1 commit into
aws:mainfrom
xyos:fix/bb-file-bucket-file-server-delete-marker
Nov 6, 2026
Merged

xyos merged 1 commit into
aws:mainfrom
xyos:fix/bb-file-bucket-file-server-delete-marker

Conversation

@xyos

@xyos xyos commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Problem

On a versioned bucket, delete(key) without a versionId writes a delete marker (versions/{key}/__deleted__) and keeps content/{key}. The mock get() honors the marker and returns null (packages/bb-file-bucket/src/index.mock.ts), but the local file server (packages/bb-file-bucket/src/file-server.ts) only checks that content/{key} exists, so a presigned GET from getUrl() keeps returning 200 with the deleted body. S3 returns 404 NoSuchKey when the current version is a delete marker.

Issue #, if available:

Changes

  • packages/bb-file-bucket/src/file-server.ts: on GET without versionId, respond with the existing 404 NoSuchKey error when the key's delete marker exists. GETs with an explicit versionId are unchanged.
  • packages/bb-file-bucket/src/file-server.test.ts: regression test for a deleted key on a versioned bucket (404, while an undeleted key still returns 200), plus a control for delete on an unversioned bucket.
  • .changeset/bb-file-bucket-file-server-delete-marker.md: patch changeset for @aws-blocks/bb-file-bucket.

Validation

  • New test GET without versionId returns 404 when the current version is a delete marker failed before the fix (deleted key must not be served, 200 !== 404) and passes after.
  • npm run build, @aws-blocks/bb-file-bucket npm test, npm run lint, npm run lint:deps: pass.
  • npm test (all workspaces) and npm run test:e2e:local from the repo root: pass.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@xyos
xyos requested a review from a team as a code owner October 29, 2026 23:49
@changeset-bot

changeset-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fd55366

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-blocks/bb-file-bucket Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@belaboe belaboe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the delete-marker 404 is right, and the test is a real regression test.

One gap worth closing here: with any versionId the new check is skipped, and an unknown versionId falls back to content/{key} (L131-137). So after delete('doc.txt'), getUrl('doc.txt', { versionId: 'v999' }), or the old URL with &versionId=v999, still returns 200 with the deleted body, while get() returns null and S3 would 404 NoSuchVersion. I'd suggest returning 404 NoSuchVersion when the version file is missing (or delegating GET to bucket.get() as PUT does), plus tests for "old version still readable after delete" and "unknown version -> 404".

Smaller: S3 also sets x-amz-delete-marker: true on this 404. Either add it, or say "matching get()" in the changeset. A line in DESIGN.md would help too.

@xyos
xyos merged commit eacc87e into aws:main Nov 6, 2026
42 checks passed
harsh62 added a commit that referenced this pull request Nov 6, 2026
Brings in 14 commits from main, among them "fix(core): return Invalid
Request for a null JSON-RPC body" (#1143), "fix(core): reject non-JSON-RPC
response bodies with ApiError" (#1171), "feat(bb-logger,core): backend Lambda
log lines carry the invocation's requestId" (#1325), #1131, #1132, #1142,
#1167, #1173, #1178, #1214, #494 and CI changes (#946, #970, #971).

packages/core/src/client/index.test.ts and lambda-handler.test.ts: keep both
sides' tests (this branch's httpErrorStatus, namespace identity and per-call
fetch suites; main's non-JSON-RPC body and request id suites).

packages/core/src/api.ts: the httpErrorStatus docs now say what the client
does since #1171 when a Hosting error page replaces a 403 / 404: it rejects
with a bare ApiError carrying the HTTP status, instead of response.json()
throwing.

# Conflicts:
#	packages/core/src/client/index.test.ts
#	packages/core/src/lambda-handler.test.ts
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