fix: return IllegalLocationConstraintException for a mismatched LocationConstraint
A region specific endpoint requires CreateBucket to name that same region in `LocationConstraint`. The gateway reported a mismatch as `InvalidLocationConstraint`, which AWS reserves for a constraint that is not a valid location at all, and accepted a request that omitted the constraint entirely. Keep `InvalidLocationConstraint` for the global `us-east-1` endpoint, which takes no constraint, and return `IllegalLocationConstraintException` when a region specific endpoint gets a constraint naming another region, or none. Fixes #2246
This commit is contained in:
1 parent
2a5705ab02
commit
2742fc2216
3 files changed
+110
-11
No files matched your search
@@ -984,6 +984,20 @@ func GetCopySourceObjectTooLargeErr(limit int64) APIError {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns illegal location constraint APIError. An empty constraint stands for
|
||||
// a CreateBucket request that carried no LocationConstraint at all.
|
||||
func GetIllegalLocationConstraintErr(constraint string) APIError {
|
||||
if constraint == "" {
|
||||
constraint = "unspecified"
|
||||
}
|
||||
|
||||
return APIError{
|
||||
Code: "IllegalLocationConstraintException",
|
||||
Description: fmt.Sprintf("The %s location constraint is incompatible for the region specific endpoint this request was sent to.", constraint),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}
|
||||
}
|
||||
|
||||
func GetInvalidRedirectCodeErr(input int) APIError {
|
||||
return APIError{
|
||||
Code: "InvalidRequest",
|
||||
|
||||
Reference in new issue
Block a user