diff --git a/docs/architecture/presigned-transfer-and-image-cdn.md b/docs/architecture/presigned-transfer-and-image-cdn.md index 37862c2c..d7ff38e6 100644 --- a/docs/architecture/presigned-transfer-and-image-cdn.md +++ b/docs/architecture/presigned-transfer-and-image-cdn.md @@ -737,8 +737,11 @@ analytics는 제품 presentation이 소유한다. 번역은 recovery 값만이 아니라 code도 본다(0929/01-01). `POLICY_REJECTED`는 `NONE`, file store의 `NOT_READABLE`/`REOPEN`은 `RESELECT`, `UPLOAD_PART`의 `NOT_FOUND`는 `RECONCILE`이다. 표 밖 값 중 `retryable:true`인 일시 오류는 -`RESUME`이다. part 발급(BFF)의 401/403은 아직 `RESUME`으로 나온다. object store -PUT 403(재발급으로 풀리는 경우)과 같은 code·단계라 번역 한 곳에서 가를 수 없다. +`RESUME`이다. part 발급(BFF)의 401/403과 object store PUT 403은 code·단계가 +같다. 그래서 출처를 아는 runtime의 발급 분기가 발급 거절을 `NONE`(retryable +`false`)으로 만든다. 세션 만료·권한 회수라 재인증 전에는 다시 불러도 같은 답이고, +재인증은 앱 세션 계층 몫이다. PUT 403은 서명 만료가 보통 원인이라 새 capability로 +풀리므로 `RESUME`이다. 관측성에는 operation, safe outcome, byte/candidate bucket, retry bucket과 failure code만 기록한다. capability ID, URL, query, asset/resource/session ID, diff --git a/src/adapters/browser-transfer/resumable-upload/resumable-upload-runtime.ts b/src/adapters/browser-transfer/resumable-upload/resumable-upload-runtime.ts index 895af0f9..011ca6aa 100644 --- a/src/adapters/browser-transfer/resumable-upload/resumable-upload-runtime.ts +++ b/src/adapters/browser-transfer/resumable-upload/resumable-upload-runtime.ts @@ -986,6 +986,13 @@ async function uploadPartWithRetry( }), ); if (!issued.ok) { + // 0929/01-01. Only this branch knows a 401/403 came from the BFF's + // issuance: the session expired or the permission was revoked, and no + // new call succeeds before the app's session layer re-authenticates. A + // PUT 403 below has the same code and stays reissuable (RESUME). + if (issued.error.code === "PERMISSION_DENIED") { + return browserDataFailure("PERMISSION_DENIED", "UPLOAD_PART"); + } lastFailure = issued.error; if (!canRetry(issued.error, attempt, dependencies.policy)) { return stripProviderFailure(issued); diff --git a/tests/unit/resumable-upload-runtime-recovery.test.ts b/tests/unit/resumable-upload-runtime-recovery.test.ts index 1fddf0e8..14f069ae 100644 --- a/tests/unit/resumable-upload-runtime-recovery.test.ts +++ b/tests/unit/resumable-upload-runtime-recovery.test.ts @@ -292,6 +292,41 @@ describe("resumable upload capability reissue (01-01)", () => { }); }); +/** + * 0929/01-01 ④. Both servers' 401/403 reach the runtime as the same + * PERMISSION_DENIED/UPLOAD_PART/REISSUE_CAPABILITY. A refused issuance means + * the session expired or the permission was revoked: no new call succeeds + * before re-authentication. A refused PUT means the signature expired: the + * runtime's next capability recovers it. + */ +describe("issuance refusal versus PUT refusal (0929/01-01)", () => { + it.each([ + ["the BFF refuses issuance with 401", "NONE", [401], [], 0], + ["the BFF refuses issuance with 403", "NONE", [403], [], 0], + ["the object store refuses every PUT with 403", "RESUME", [], [403, 403, 403, 403], 4], + ] as const)( + "%s → %s", + async (_scenario, recovery, issueStatuses, putStatuses, puts) => { + const real = presignedRuntime(putStatuses, undefined, { issueStatuses }); + + const result = await real.runtime.upload( + request("upload_key_permission_denied"), + ); + + expect(result).toMatchObject({ + ok: false, + error: { + code: "PERMISSION_DENIED", + operation: "UPLOAD_PART", + retryable: false, + recovery, + }, + }); + expect(real.puts()).toBe(puts); + }, + ); +}); + describe("part-stage Retry-After (2026-11-01 01-01)", () => { const stages = [ { stage: "BFF issuance", issueStatuses: [429], putStatuses: [] },