Files
seaweedfs/weed/s3api/s3err
b69076476b s3api: return KMS errors on SSE-KMS writes as their S3 error codes (#13379)
* s3api: return KMS errors on SSE-KMS writes as their S3 error codes

An SSE-KMS PutObject, UploadPart, UploadPartCopy or CopyObject naming a
key the KMS doesn't have failed with 500 InternalError, and so did a
plain upload to a bucket whose default encryption names one.

MapKMSErrorToS3Error never saw these errors. The put path returned
InternalError for every encryption failure. The copy path compared the
mapper's result against InvalidRequest, which it never returns, so it
answered InternalError for every error and its SSE-C check after it
never ran. And the KMS calls wrapped the provider's error with %v, so
its type was gone before any of them looked.

Wrap the provider errors with %w, find the KMS error with errors.As,
and map encryption failures on the put path, the bucket default put
and the inline copy path. A missing key is now 400
KMSKeyNotFoundException, a disabled one 400 KMSKeyDisabledException,
and errors that don't come from KMS stay 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: map wrapped SSE-C errors to their S3 codes

A destination SSE-C parse error reaches the copy error mapper wrapped
with %w, so the exact-match switch missed it and the copy answered 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3err: answer KMS key errors with the codes AWS S3 uses

AWS S3 reports a missing SSE-KMS key as KMS.NotFoundException, a
disabled one as KMS.DisabledException, and a denied KMS call as
AccessDenied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-04 11:06:26 -08:00
..