oscerd opened a new pull request, #28953: URL: https://github.com/apache/camel/pull/28953
Fixes [CAMEL-26262](https://issues.apache.org/jira/browse/CAMEL-26262), found while adding the catalog body types (CAMEL-24961). ## 1. The putLogs examples set a text body, which fails **Was:** the putLogs examples of `alibaba-sls-component.adoc` set the body with `setBody(simple("${body}"))` (Java) and a `simple` setBody (YAML), so a text body reached the producer, which takes only a `LogGroup` or a `PutLogsRequest` and fails with `IllegalArgumentException: Body must be LogGroup or PutLogsRequest for putLogs`. **Now:** the doc shows a small bean, `com.example.SlsLogs`, that builds a `LogGroup` of one log (the time in seconds since the epoch, and the text under the key `message`), and both examples call it before `putLogs`: `.bean(SlsLogs.class, "toLogGroup")` in Java and a `bean` step with `beanType` and `method` in YAML. The YAML was checked against the YAML DSL schema. The text before the examples says what a log group holds and that any other body, such as text, fails. ## Tests - New `PutLogsDocExampleTest` (2 tests) with a mocked SLS `Client`: the Java route of the docs, with a copy of the bean, sends a `PutLogsRequest` whose `LogGroup` has the topic, one log with the current time and the text under `message`; the route of the earlier example, which sets a text body, fails with the `IllegalArgumentException` and does not call SLS. - Revert check: not applicable, as there is no `src/main` code change; the test runs the earlier example as well, which fails. - Module: 10 tests, 0 failures. ## Docs and generated files - Component doc: the putLogs examples and the text before them. The doc copied into `camel-catalog`. - Body types: unchanged, they already say that putLogs takes a `LogGroup` or a `PutLogsRequest` and that any other body fails. The component JSON does not change. - Upgrade guide: none. ## Not changed - A text body still fails: turning it into a log needs a key, a time and maybe a topic and a source, which the component would have to choose. **Open question:** accept a String as one log under a fixed key, such as `content`, which the simple mode of Logtail uses for a raw log line? 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]
