davsclaus opened a new pull request, #28356: URL: https://github.com/apache/camel/pull/28356
Fixes [CAMEL-26105](https://issues.apache.org/jira/browse/CAMEL-26105). **The problem.** The `startQueryExecution` operation of the aws2-athena producer, which is its default operation, took the SQL from the message body first, then from the `CamelAwsAthenaQueryString` header, and from the `queryString` option only when both were empty (`Athena2Producer.determineQueryString`). So an endpoint configured with `queryString` did not run that query whenever the message had a body: it ran the text of the body instead. For example, a second `startQueryExecution` after one with `waitTimeout` sent the `toString()` of the `GetQueryExecutionResponse` that the first one left as the body. The documentation did not state this order. With `includeTrace=true`, the SQL comment held the URI of the from endpoint as is, without the masking Camel applies when it logs endpoint URIs, and it failed with a `NullPointerException` when the exchange had no from endpoint (an exchange built by hand). **The change.** - New producer option `useMessageBodyForSql` (default `false`), named as in camel-sql. - `startQueryExecution` takes the SQL from the `CamelAwsAthenaQueryString` header, then from the `queryString` option. With `useMessageBodyForSql=true`, a non-empty body comes first, as before. - When no SQL is found, the `IllegalArgumentException` names the header, `queryString` and `useMessageBodyForSql`, so a route that relied on the body fails with a clear message. - `includeTrace`: the URI of the from endpoint is written with `URISupport.sanitizeUri`, and left out when the exchange has no from endpoint. - The descriptions of `queryString` and of the header state the order. Regenerated: the component JSON, configurers and URI factory, the catalog, the endpoint DSL and the component DSL. - Docs: a "Where the SQL comes from" section with an example that sets the header. The examples that set the SQL in the body (Java, XML and YAML) now set `useMessageBodyForSql=true`. - Upgrade guide 4.24 entry. **Tests** - New `Athena2ProducerQueryStringTest` (8 tests), using the client mock, which now keeps the last `StartQueryExecutionRequest`. Run against the producer without the change, 6 of them fail: - the body ran instead of the `queryString` option (`expected: <SELECT 1> but was: <Hello World>`) and instead of the header; - no error was raised without a query; - the `GetQueryExecutionResponse` of the earlier step ran as the SQL; - the trace comment held the endpoint URI without masking; - the `NullPointerException` without a from endpoint. The 2 tests of `useMessageBodyForSql=true` pass with and without the change, as that option keeps the previous order. - `AthenaComponentTest` and `AthenaComponentManualIT` send the SQL in the body, so their startQueryExecution endpoints set `useMessageBodyForSql=true`. `AthenaEndpointTest` and `AthenaComponentConfigurationTest` cover the new option. - camel-aws2-athena: 61 tests, 0 failures. The 14 tests of `AthenaComponentManualIT` need AWS credentials and were skipped. - `mvn clean install -DskipTests` from the root folder is green. It regenerated only the aws2-athena files of the catalog, the endpoint DSL and the component DSL, which are committed. - The doc example checks pass against the regenerated catalog: `DocExamplesXmlSchemaTest` and `DocExamplesJavaImportsTest` (camel-catalog), `EipDocExamplesTest` (camel-yaml-dsl-validator), and `CatalogDocExamplesTest` and `CatalogDocJavaExamplesTest` (camel-jbang-core). **Related** - #28343 (CAMEL-24961) adds catalog body types for aws2-athena that describe the body as the SQL. That text needs the same change when the stack is rebased onto this. - CAMEL-26100 changes the same producer (the outputs of an earlier `startQueryExecution` taken as inputs of the next one). - The backports to 4.22.x and 4.18.x, as planned in the JIRA, change only the order (header, option, then body), without the new option. Their upgrade guide notes come with them. _Claude Code on behalf of davsclaus_ 🤖 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]
