Priyesh Karatha created HDDS-16372:
--------------------------------------

             Summary:  PutBucketLifecycleConfiguration returns generic "Invalid 
Request" message for a past Expiration Date
                 Key: HDDS-16372
                 URL: https://issues.apache.org/jira/browse/HDDS-16372
             Project: Apache Ozone
          Issue Type: Sub-task
            Reporter: Priyesh Karatha


While testing the S3 bucket lifecycle configuration, providing an 
Expiration.Date in the past results in an HTTP 400 error. However, the response 
does not indicate that the date is invalid because it is in the past. Instead, 
the client receives only the generic error message: Invalid Request.

Steps to Reproduce

Create a lifecycle configuration with an expiration date in the past:

cat > /tmp/lifecycle.json <<EOF
{
  "Rules": [{
    "ID": "expire-key1-fso",
    "Status": "Enabled",
    "Filter": \{ "Prefix": "key1/" },
    "Expiration": \{ "Date": "2020-01-01T00:00:00Z" }
  }]
}
EOF


Run the following command:

ozones3api put-bucket-lifecycle-configuration \
  --bucket "$BUCKET" \
  --lifecycle-configuration file:///tmp/lifecycle.json

Actual Result

The request fails with HTTP 400 and the following generic error:

An error occurred (InvalidRequest) when calling the 
PutBucketLifecycleConfiguration operation: Invalid Request

Expected Result

The response should provide a meaningful error message indicating that the 
specified expiration date is invalid because it is in the past.

For example:

The expiration date must not be earlier than the bucket creation time.

Root Cause

S3LifecycleConfiguration.toOmLifecycleConfiguration() builds the OM model with 
creationTime=0. As a result, the S3 Gateway's client-side validation cannot 
determine whether the specified expiration date is genuinely in the past.

The actual validation is performed by OM in 
OmLCExpiration#validateExpirationDate, which uses the bucket's actual creation 
time. This validation is triggered when BucketEndpoint calls:

ozoneBucket.setLifecycleConfiguration(...)


BucketLifecycleHandler.putBucketLifecycleConfiguration() catches the resulting 
OMException and converts it to an OS3Exception using:

S3ErrorTable.newError(bucketName, ex)


However, the OS3Exception constructor sets errorMessage to the static, generic 
message from S3ErrorTable. It does not preserve ex.getMessage() from the 
underlying OMException, causing the detailed validation message from OM to be 
lost.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to