diff --git a/src/adapters/http/fileserver-upload.ts b/src/adapters/http/fileserver-upload.ts index b9171dfb..47646e07 100644 --- a/src/adapters/http/fileserver-upload.ts +++ b/src/adapters/http/fileserver-upload.ts @@ -643,10 +643,15 @@ function envelopeFailure( const waitRefused = retryAfterMs !== null && retryAfterMs > settings.maxRetryAfterMs; const reading = envelopeFailureReading(status, error); - // A file the server refuses by size or type is the user's to replace, as - // the same refusal before sending is (`readMultipartBody`). - const kind: FailureKind = - status === 413 || status === 415 ? "VALIDATION_REJECTED" : reading.kind; + // A file the server refuses by size, type, digest, signature or scan is the + // user's to replace, as the same refusal before sending is + // (`readMultipartBody`). A 422 for a reused key with another body is not + // about the file and reads as the shared table reads it (2026-11-03 08-05). + const fileRefused = + status === 413 || + status === 415 || + (status === 422 && error.code !== "IDEMPOTENT_REQUEST_MISMATCH"); + const kind: FailureKind = fileRefused ? "VALIDATION_REJECTED" : reading.kind; const created = createFailure(kind, FILESERVER_UPLOAD_OPERATION_ID, 0, { code: reading.code, httpStatus: status, diff --git a/tests/integration/fileserver-upload.test.ts b/tests/integration/fileserver-upload.test.ts index 0d8d8904..ec5bd27b 100644 --- a/tests/integration/fileserver-upload.test.ts +++ b/tests/integration/fileserver-upload.test.ts @@ -317,7 +317,7 @@ describe("Fileserver multipart upload — Envelope failures", () => { { status: 413, code: "QUOTA_EXCEEDED", category: "CONFLICT", retryable: false, kind: "VALIDATION_REJECTED", effect: "NOT_APPLIED", clientRetryable: false }, { status: 415, code: "UNSUPPORTED_MEDIA_TYPE", category: "VALIDATION", retryable: false, kind: "VALIDATION_REJECTED", effect: "NOT_APPLIED", clientRetryable: false }, { status: 422, code: "MALWARE_DETECTED", category: "DATA_INTEGRITY", retryable: false, kind: "VALIDATION_REJECTED", effect: "NOT_APPLIED", clientRetryable: false }, - { status: 422, code: "IDEMPOTENT_REQUEST_MISMATCH", category: "VALIDATION", retryable: false, kind: "VALIDATION_REJECTED", effect: "NOT_APPLIED", clientRetryable: false }, + { status: 422, code: "IDEMPOTENT_REQUEST_MISMATCH", category: "VALIDATION", retryable: false, kind: "UNKNOWN_CLIENT_FAILURE", effect: "NOT_APPLIED", clientRetryable: false }, { status: 500, code: "PARTIAL_WRITE", category: "TRANSIENT_DEPENDENCY", retryable: false, kind: "SERVER_FAILURE", effect: "NOT_APPLIED", clientRetryable: false }, { status: 500, code: "AMBIGUOUS_COMPLETION", category: "DATA_INTEGRITY", retryable: false, details: { ambiguous: true, reconciliationRequired: true }, kind: "SERVER_FAILURE", effect: "MAYBE_APPLIED", clientRetryable: false }, { status: 500, code: "INTERNAL_ERROR", category: "INTERNAL", retryable: false, kind: "SERVER_FAILURE", effect: "MAYBE_APPLIED", clientRetryable: false },