Skip to content

Conversation

@sreejasahithi
Copy link
Contributor

@sreejasahithi sreejasahithi commented May 14, 2025

What changes were proposed in this pull request?

AWS S3 PutObject API allows creating keys and directories with names containing invalid characters, but delete operation fails to remove such invalid objects from a FSO bucket. Hence to resolve this issue, key name validation should not be done during the key deletion.

For example :
Before :
aws s3api --endpoint http://localhost:9878/ put-object --bucket fsobuck --key sampledir:1/ --no-verify-ssl
this has no error and gets created successfully.
but when we try to delete it we get an error as follows,
An error occurred (500) when calling the DeleteObject operation (reached max retries: 4): Internal Server Error

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-12911

How was this patch tested?

https://github.com/sreejasahithi/ozone/actions/runs/15020991860

This change was also tested locally over a docker ozone cluster.
Added a testcase in TestOMKeyDeleteRequestWithFSO.java

@sreejasahithi sreejasahithi marked this pull request as ready for review May 14, 2025 14:03
Copy link
Contributor

@sarvekshayr sarvekshayr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @sreejasahithi.
I tested the validation, and it works as expected.

Currently, characters like ,, ., .., etc., are allowed during the put-object operation, and delete-object is able to handle such entries unlike the : case. We can leave these as is for now and focus only on excluding : as implemented.

cc: @nandakumar131

@adoroszlai adoroszlai added the s3 S3 Gateway label May 15, 2025
@sreejasahithi sreejasahithi requested a review from sadanand48 May 15, 2025 10:08
…ad of splitting and made error message robust
@sreejasahithi sreejasahithi requested a review from sadanand48 May 19, 2025 05:36
@sadanand48
Copy link
Contributor

sadanand48 commented May 20, 2025

I looked into this and the reason for the corner case of put-object allowing a key like "sample:/" is because if the --body is not provided , it gets translated into a CreateDirectory operation for an FSO bucket

$ aws s3api --endpoint http://xx:9878 put-object --bucket buck2 --key sample:/

$ aws s3api --endpoint http://xx:9878 delete-object --bucket buck2 --key sample:/

An error occurred (500) when calling the DeleteObject operation (reached max retries: 2): Internal Server Error

The keyName check is controlled by a flag ozone.om.keyname.character.check.enabled which was introduced here and defaults to false.
But the logic in OmDeleteKeyRequest is different i.e it does not call the same validateKey() method but instead calls validateAndNormalizeKey which internally only validates if the bucket is FSO.

To not allow these chars in the first place, I feel one should tune this config to true for stricter char check or we could even change default to true.

@adoroszlai what do you think?.

@adoroszlai
Copy link
Contributor

adoroszlai commented Jun 13, 2025

Thanks @sadanand48, @sarvekshayr, @sreejasahithi for the discussion so far, and sorry for the delayed response. Can we continue allowing : and try to fix delete operation?

  1. Suddenly starting to reject certain characters due to implementation detail may break things.
  2. S3 doc says : may need special care, not that it is invalid.

CC @ivandika3

@sadanand48
Copy link
Contributor

continue allowing : and try to fix delete operation

Yeah we should keep the behaviour consistent b/w create and delete. Both use different methods to validate key name today causing the discrepancy. The validation for extra chars should only be done during create/rename key if the strict check flag is switched on and not do this validation on delete or any other API

@adoroszlai adoroszlai marked this pull request as draft June 13, 2025 12:25
@ivandika3
Copy link
Contributor

+1 on not restricting the naming without understanding fully the possible regressions and instead fixing the specific case.

@SaketaChalamchala
Copy link
Contributor

Agree that we should be able to delete existing keys and any new restrictions on key names should be behind the character check strictness flag.

@sreejasahithi
Copy link
Contributor Author

Currently, validateAndNormalizeKey is used by both OMKeyDeleteRequest and OMKeyCreateRequest, which results in unnecessary key name validation during deletes operations.

Since key name validation is not necessary during delete operations, because we should be able to delete any key that was allowed to be created. To address this, I propose introducing a separate method for normalizing key paths specifically for OMKeyDeleteRequest. This new method would perform key name validation (i.e invokes isValidKeyPath) only if the configuration flag keyNameCharacterCheckEnabled is set to true, thereby preserving the existing behavior. Other operations like create or rename can continue using the existing validateAndNormalizeKey flow without any changes.

Alternatively, we could instead add a check for keyNameCharacterCheckEnabled directly inside validateAndNormalizeKey. However, this approach might affect all other operations that use this method.

CC @adoroszlai , @sadanand48 , @ivandika3 , @SaketaChalamchala

@sadanand48
Copy link
Contributor

Yes @sreejasahithi we should modify the code to have a similar behaviour as the method added in HDDS-13262, basically maintain consistent behaviour for these checks.

Copy link
Contributor

@sadanand48 sadanand48 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sreejasahithi for updating the patch. I am okay with this patch which unblocks delete of keys with special chars.

@sadanand48 sadanand48 requested a review from adoroszlai July 9, 2025 08:46
@sreejasahithi sreejasahithi requested a review from sadanand48 July 9, 2025 15:41
@sreejasahithi
Copy link
Contributor Author

sreejasahithi commented Jul 9, 2025

The newly added testcase testDeleteKeyWithColonInFSOBucket fails in CI , I am fixing it.

@sreejasahithi
Copy link
Contributor Author

I have fixed the testcase issue.

@sreejasahithi sreejasahithi marked this pull request as ready for review July 10, 2025 13:07
@sreejasahithi sreejasahithi requested a review from adoroszlai July 11, 2025 08:06
@adoroszlai adoroszlai changed the title HDDS-12911. Add key name validation to AWS S3 PutObject API HDDS-12911. Key deletion should not validate the name Jul 11, 2025
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sreejasahithi for updating the patch.

@sreejasahithi sreejasahithi requested a review from adoroszlai July 14, 2025 06:44
@sadanand48 sadanand48 merged commit 04a359d into apache:master Jul 18, 2025
42 checks passed
@sadanand48
Copy link
Contributor

Thanks @sreejasahithi for the patch, @adoroszlai @SaketaChalamchala @ivandika3 @sarvekshayr for the reviews and discussions.

jojochuang pushed a commit to jojochuang/ozone that referenced this pull request Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants