fix(aws): make S3 emulator compatible with official AWS SDK wire format#65
fix(aws): make S3 emulator compatible with official AWS SDK wire format#65jlucaso1 wants to merge 1 commit intovercel-labs:mainfrom
Conversation
S3 routes now use root paths (GET /, PUT /:bucket, GET /:bucket/:key) matching the real S3 wire protocol, so @aws-sdk/client-s3 works out of the box with forcePathStyle. Legacy /s3/ prefixed paths are preserved as backward-compatible aliases. Also adds presigned POST uploads (POST /:bucket) with policy validation, ListObjectsV2 pagination via continuation-token/start-after, and moves the inspector UI to /_inspector so GET / is free for ListBuckets.
|
@jlucaso1 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 424f1d2ea6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const successStatus = parseInt(body["success_action_status"] as string, 10); | ||
| if (successStatus === 201) { | ||
| const xml = `<?xml version="1.0" encoding="UTF-8"?> | ||
| <PostResponse> | ||
| <Location>${escapeXml(baseUrl)}/${escapeXml(bucketName)}/${escapeXml(key)}</Location> | ||
| <Bucket>${escapeXml(bucketName)}</Bucket> | ||
| <Key>${escapeXml(key)}</Key> | ||
| <ETag>"${etag}"</ETag> | ||
| </PostResponse>`; | ||
| return awsXmlResponse(c, xml, 201); | ||
| } | ||
|
|
||
| return c.body(null, 204); |
There was a problem hiding this comment.
Return 200 when success_action_status requests it
POST /:bucket only checks for success_action_status === 201 and otherwise always returns 204, so uploads that specify success_action_status=200 get the wrong status code even though the object is stored. S3 clients that rely on the requested success status can treat this as a failed upload flow; add an explicit 200 branch before the default 204 response.
Useful? React with 👍 / 👎.
Summary
The S3 emulator was unreachable by any official AWS SDK because routes lived under a
/s3/prefix (GET /s3/,PUT /s3/:bucket, etc.), while every AWS SDK sends requests to root paths (GET /,PUT /:bucket). The inspector UI atGET /also collided withListBuckets, and presigned POST uploads were missing entirely.@aws-sdk/client-s3works withforcePathStyle: true. Legacy/s3/prefixed paths are preserved as backward-compatible aliases (registered first so Hono's router resolves them before the wildcard/:bucketroutes).POST /:bucket) with policy validation: expiration checks,content-length-rangeenforcement, andstarts-withcondition matching on form fields.continuation-tokenandstart-afterquery parameters withNextContinuationTokenin truncated responses.GET /toGET /_inspectorso the root path is free forListBuckets./:bucketfrom shadowing static paths.packages/@emulators/aws/README.md,skills/aws/SKILL.md,apps/web/app/aws/page.mdx.Test plan
success_action_status, policy enforcement (content-length-range, starts-with, expiration)max-keys,continuation-token,start-after/s3/aliases: list buckets, put/get objects via legacy paths/_inspectorstill renders S3/SQS/IAM tabsGET /returns XMLListAllMyBucketsResult, not HTML inspectorpnpm build && pnpm format:check && pnpm type-check && pnpm lint && pnpm testall pass@aws-sdk/client-s3ListBuckets, PutObject, GetObject, HeadObject, DeleteObject, CopyObject, ListObjectsV2@aws-sdk/s3-presigned-postcreatePresignedPost flow