You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "priyeshkaratha (via GitHub)" <gi...@apache.org> on 2026/09/21 07:08:32 UTC

[PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

priyeshkaratha opened a new pull request, #11290:
URL: https://github.com/apache/ozone/pull/11290

   ## What changes were proposed in this pull request?
   PutBucketLifecycleConfiguration accepted a Days value that overflows a 32-bit int (e.g. `3323232323232323232323232323232323232323232`) and returned HTTP 200. JAXB's built-in Integer converter silently wrapped the value, so a subsequent GetBucketLifecycleConfiguration returned a different, unrelated value (`347068064`) than what was submitted which is risking unexpected object expiration behavior.
   
   Bind `Expiration.Days` and `AbortIncompleteMultipartUpload.DaysAfterInitiation` as raw `String` in `S3LifecycleConfiguration` instead of `Integer`, and parse them explicitly in a shared `parseDays()` helper that throws
   `IllegalArgumentException` on a non-integer or out-of-range value. This surfaces as an `INVALID_ARGUMENT` (HTTP 400) S3 error with a message naming the offending value, instead of silently truncating it.
   
   ## What is the link to the Apache JIRA
   
   HDDS-16393
   
   ## How was this patch tested?
   
   Tested using added test-cases.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #11290:
URL: https://github.com/apache/ozone/pull/11290#issuecomment-5773450943

   https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-lifecycle-configuration.html
   
   says that 
   ```
   Days -> (integer)
   
       Indicates the number of days after creation when objects are transitioned to the specified storage class. The value can be 0 or any positive integer.
   ```
   
   @priyeshkaratha , could you double check if negative value is allowed or not ? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "priyeshkaratha (via GitHub)" <gi...@apache.org>.
priyeshkaratha commented on PR #11290:
URL: https://github.com/apache/ozone/pull/11290#issuecomment-5780335299

   
   > @priyeshkaratha , could you double check if negative value is allowed or not ?
   Yes, its not allowed. will throw following error
   
   `An error occurred (InvalidArgument) when calling the PutBucketLifecycleConfiguration operation: 'Days' for Expiration action must be a positive integer greater than zero.`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #11290:
URL: https://github.com/apache/ozone/pull/11290#discussion_r4078830353


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:
##########
@@ -168,14 +170,30 @@ public void setDate(String date) {
   @XmlRootElement(name = "AbortIncompleteMultipartUpload")
   public static class AbortIncompleteMultipartUpload {
     @XmlElement(name = "DaysAfterInitiation")
-    private Integer daysAfterInitiation;
+    private String daysAfterInitiation;
 
     public Integer getDaysAfterInitiation() {
-      return daysAfterInitiation;
+      return parseDays(daysAfterInitiation);
     }
 
     public void setDaysAfterInitiation(Integer daysAfterInitiation) {
-      this.daysAfterInitiation = daysAfterInitiation;
+      this.daysAfterInitiation = daysAfterInitiation == null ? null : daysAfterInitiation.toString();
+    }
+  }
+
+  /**
+   * Parses a lifecycle day-count element, rejecting a value that does not fit in an int instead
+   * of silently overflowing it the way JAXB's built-in Integer converter would.
+   */
+  private static Integer parseDays(String value) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return Integer.parseInt(value.trim());
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid lifecycle configuration: Days value '" + value

Review Comment:
   Let's show the consistent error message here,
   
   `'Days' for Expiration action must be a positive integer greater than zero.`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "priyeshkaratha (via GitHub)" <gi...@apache.org>.
priyeshkaratha commented on PR #11290:
URL: https://github.com/apache/ozone/pull/11290#issuecomment-5791183624

   Thanks @ChenSammi for reviewing the changes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #11290:
URL: https://github.com/apache/ozone/pull/11290#discussion_r4078830353


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:
##########
@@ -168,14 +170,30 @@ public void setDate(String date) {
   @XmlRootElement(name = "AbortIncompleteMultipartUpload")
   public static class AbortIncompleteMultipartUpload {
     @XmlElement(name = "DaysAfterInitiation")
-    private Integer daysAfterInitiation;
+    private String daysAfterInitiation;
 
     public Integer getDaysAfterInitiation() {
-      return daysAfterInitiation;
+      return parseDays(daysAfterInitiation);
     }
 
     public void setDaysAfterInitiation(Integer daysAfterInitiation) {
-      this.daysAfterInitiation = daysAfterInitiation;
+      this.daysAfterInitiation = daysAfterInitiation == null ? null : daysAfterInitiation.toString();
+    }
+  }
+
+  /**
+   * Parses a lifecycle day-count element, rejecting a value that does not fit in an int instead
+   * of silently overflowing it the way JAXB's built-in Integer converter would.
+   */
+  private static Integer parseDays(String value) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return Integer.parseInt(value.trim());
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid lifecycle configuration: Days value '" + value

Review Comment:
   Let's show an error message like this,
   
   `"Invalid lifecycle configuration: Days value '" + value + "' is not a valid integer", e);`
   
   `Days value + "' must be an integer between " + Integer.MIN_VALUE + " and " + Integer.MAX_VALUE` will mislead user. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "priyeshkaratha (via GitHub)" <gi...@apache.org>.
priyeshkaratha merged PR #11290:
URL: https://github.com/apache/ozone/pull/11290


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #11290:
URL: https://github.com/apache/ozone/pull/11290#discussion_r4078830353


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:
##########
@@ -168,14 +170,30 @@ public void setDate(String date) {
   @XmlRootElement(name = "AbortIncompleteMultipartUpload")
   public static class AbortIncompleteMultipartUpload {
     @XmlElement(name = "DaysAfterInitiation")
-    private Integer daysAfterInitiation;
+    private String daysAfterInitiation;
 
     public Integer getDaysAfterInitiation() {
-      return daysAfterInitiation;
+      return parseDays(daysAfterInitiation);
     }
 
     public void setDaysAfterInitiation(Integer daysAfterInitiation) {
-      this.daysAfterInitiation = daysAfterInitiation;
+      this.daysAfterInitiation = daysAfterInitiation == null ? null : daysAfterInitiation.toString();
+    }
+  }
+
+  /**
+   * Parses a lifecycle day-count element, rejecting a value that does not fit in an int instead
+   * of silently overflowing it the way JAXB's built-in Integer converter would.
+   */
+  private static Integer parseDays(String value) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return Integer.parseInt(value.trim());
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid lifecycle configuration: Days value '" + value

Review Comment:
   Let's show the consistent error message,
   
   `'Days' for Expiration action must be a positive integer greater than zero.`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-16393. Reject oversized Days values in PutBucketLifecycle [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #11290:
URL: https://github.com/apache/ozone/pull/11290#discussion_r4078830353


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:
##########
@@ -168,14 +170,30 @@ public void setDate(String date) {
   @XmlRootElement(name = "AbortIncompleteMultipartUpload")
   public static class AbortIncompleteMultipartUpload {
     @XmlElement(name = "DaysAfterInitiation")
-    private Integer daysAfterInitiation;
+    private String daysAfterInitiation;
 
     public Integer getDaysAfterInitiation() {
-      return daysAfterInitiation;
+      return parseDays(daysAfterInitiation);
     }
 
     public void setDaysAfterInitiation(Integer daysAfterInitiation) {
-      this.daysAfterInitiation = daysAfterInitiation;
+      this.daysAfterInitiation = daysAfterInitiation == null ? null : daysAfterInitiation.toString();
+    }
+  }
+
+  /**
+   * Parses a lifecycle day-count element, rejecting a value that does not fit in an int instead
+   * of silently overflowing it the way JAXB's built-in Integer converter would.
+   */
+  private static Integer parseDays(String value) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return Integer.parseInt(value.trim());
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid lifecycle configuration: Days value '" + value

Review Comment:
   Let's show the consistent error message here,
   
   `"Invalid lifecycle configuration: Days value '" + value + "' is not a valid integer", e);`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org