oscerd opened a new pull request, #28967: URL: https://github.com/apache/camel/pull/28967
Fixes [CAMEL-26268](https://issues.apache.org/jira/browse/CAMEL-26268), found while adding the catalog body types (CAMEL-24961). ## 1. putObject with a File body skips the bucket name check **Was:** the check `(bucketName empty || objectName empty) && !(body instanceof File)` skipped both names for a File body, though only the object name can come from the file. Without a bucket name, putObject went on to `obsClient.headBucket(null)`, where the SDK failed. With a client that does not check the name (such as a mock), it went on to create a bucket and to put the object with a null bucket name. The same happened with the GenericFile of a file consumer, which is unwrapped to its File. **Now:** the bucket name is checked for every body before the client is called, and a missing one fails with `IllegalArgumentException: Bucket name is mandatory to put objects into bucket`. The object name is still needed only when the body is not a File, whose name is the default. A missing object name now has its own message. This is what the comment above the check and the component doc already said. ## Tests - New `PutObjectMandatoryNamesTest` (5 tests) with a Mockito `ObsClient` set on the endpoint (`obsClient=#obsClient`). A File and the GenericFile of a file consumer without a bucket name fail before any call to the client. A text without a bucket name or without an object name fails. A File without an object name is put with the name of the file. - With the `src/main` change reverted, 2 of the 5 new tests fail on the bug: the File and the GenericFile without a bucket name reached the client (`headBucket(null)`, then `createBucket` and `putObject` with a null bucket name), and the exchange completed. The 3 that pass are cases that already failed (a text without a bucket name or an object name) or already worked (a File without an object name). - Module: 52 tests, 0 failures, 18 skipped (the functional tests, which need a Huawei Cloud account). ## Docs and generated files None. The component doc already says that `bucketName` is required for putObject and that the file name is the default object name, and the body types of putObject say so too, so the generated files do not change. No upgrade-guide entry: the call failed before too, in the SDK. Main only, as the other fixes of the CAMEL-24961 follow-ups. _Claude Code on behalf of Andrea Cosentino (oscerd)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
