05f21d764f34
send the HEAD an S3 tag check is signed for, so tarballs and release deletes stop failing with 403 (v3.2.13)
- time
- 2026-11-18 01:21 UTC · 1 week ago
- machine
- Junes-MacBook-Pro.local
- agent
- claude-opus-5-5
- session
- verify review findings
- parent
- 0f06d3e76e90
↓ kepr-05f21d76.tar.gzatlas at this save
files changed3 files
package.json+1 −1src/bucket/reader.ts+4 −1tests/bucket.test.ts+26 −0package.json+1 −1
@@ -1,6 +1,6 @@11 {22 "name": "kepr",3- "version": "3.2.12",3+ "version": "3.2.13",44 "private": true,55 "type": "module",66 "scripts": {src/bucket/reader.ts+4 −1
@@ -183,7 +183,10 @@183183 },184184 async tag(key) {185185 // HEAD, not stat: a missing key is a 404 to check for, not an error Bun's reader types.186- const response = await fetch(client.presign(key, { method: "HEAD", expiresIn: 60 }));186+ // Signed for HEAD, so a plain fetch's GET would be refused with 403.187+ const response = await fetch(client.presign(key, { method: "HEAD", expiresIn: 60 }), {188+ method: "HEAD",189+ });187190 if (response.status === 404) return null;188191 if (!response.ok) throw new Error(`S3 HEAD ${key} failed: HTTP ${response.status}`);189192 const tag = response.headers.get("etag");tests/bucket.test.ts+26 −0
@@ -369,3 +369,29 @@369369 }370370 });371371 });372+373+test("an S3 bucket's tag check sends the HEAD its URL is signed for", async () => {374+ // A real S3 refuses a request whose method differs from the signed one, as Scaleway did.375+ const methods: string[] = [];376+ const stub = Bun.serve({377+ port: 0,378+ fetch(request) {379+ methods.push(request.method);380+ return new Response(null, { status: request.method === "HEAD" ? 404 : 403 });381+ },382+ });383+ try {384+ const bucket = openBucket({385+ kind: "s3",386+ endpoint: `http://127.0.0.1:${stub.port}`,387+ name: "koh",388+ region: "fr-par",389+ accessKeyId: "KEY-ID",390+ secretAccessKey: "KEY-SECRET",391+ });392+ expect(await bucket.tag(".kepr/tarballs/app/missing.tar.gz")).toBeNull();393+ expect(methods).toEqual(["HEAD"]);394+ } finally {395+ stub.stop(true);396+ }397+});