fix(s3): keep checksum-type validation off the s3s error macro

The s3s footprint ratchet (scripts/check_s3s_footprint.sh) counts
s3_error! invocation lines and is lower-only: new code must route
through the gateway abstractions rather than widen the direct s3s
surface the s3gate migration is shrinking.

Raise the contradiction through ApiError::invalid_request instead. The
response is byte-for-byte identical -- From<ApiError> for S3Error carries
the InvalidRequest code and the message through unchanged -- and the
usecase already returns ApiError elsewhere, so this is the idiomatic
path rather than a way around the counter.

The explanatory comment deliberately says "the s3s error macro" instead
of naming the macro: the ratchet counts raw matches, so spelling it out
in a comment tripped the same check.
This commit is contained in:
唐小鸭
2026-09-02 23:53:27 +08:00
parent af4d66173c
commit 51b632bb10
+6 -3
View File
@@ -320,10 +320,13 @@ fn validate_complete_multipart_checksum_type(headers: &HeaderMap, upload_metadat
};
if requested != recorded {
return Err(s3_error!(
InvalidRequest,
// Routed through `ApiError` rather than the s3s error macro so this
// validation does not widen the direct s3s surface the s3gate migration
// is shrinking (scripts/check_s3s_footprint.sh); the response is identical.
return Err(ApiError::invalid_request(format!(
"The upload was created with checksum type {recorded}. The complete request must use the same checksum type, got {requested}."
));
))
.into());
}
Ok(())