storj / edge

Storj edge services (including multi-tenant, S3-compatible server to interact with the Storj network)
GNU Affero General Public License v3.0
54 stars 18 forks source link

PutObjectLockConfiguration incorrect error codes returned #528

Open halkyon opened 5 days ago

halkyon commented 5 days ago

PutObjectLockConfiguration for invalid lock config on AWS S3 has two different error codes, since AWS doesn't seem to be consistent here:

At the moment, we return InvalidArgument for either of the above cases, so we need to return a different code for the second case if we want to fix these tests:

Upstream Minio also has the same problem, so we would need to patch our fork with new code to make the changes: https://github.com/storj/minio/blob/main/cmd/bucket-handlers.go#L1058

halkyon commented 1 day ago

Example cases:

[cloudshell-user@ip-10-132-73-175 ~]$ aws s3api put-object-lock-configuration \
--bucket bucket \
--object-lock-configuration 'ObjectLockEnabled=string,Rule={DefaultRetention={Mode=a,Days=1,Years=1}}'

An error occurred (MalformedXML) when calling the PutObjectLockConfiguration operation: The XML you provided was not well-formed or did not validate against our published schema

MalformedXML is returned for invalid or missing fields, like ObjectLockEnabled, and DefaultRetention. From what I can tell, it only ever returns a generic malformed XML error with no specific details.

More specific InvalidArgument error cases occur for the following:

[cloudshell-user@ip-10-132-73-175 ~]$ aws s3api put-object-lock-configuration \
--bucket bucket \
--object-lock-configuration 'ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=GOVERNANCE,Days=-1}}'

An error occurred (InvalidArgument) when calling the PutObjectLockConfiguration operation: Default retention period must be a positive integer value.
[cloudshell-user@ip-10-132-73-175 ~]$ aws s3api put-object-lock-configuration \
--bucket bucket \
--object-lock-configuration 'ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=GOVERNANCE,Days=999999999}}'

An error occurred (InvalidArgument) when calling the PutObjectLockConfiguration operation: Default retention period too large.
storj-gerrit[bot] commented 1 day ago

Change {cmd,pkg}: fix error codes returned for PutObjectLockConfiguration mentions this issue.