oscerd opened a new pull request, #29073:
URL: https://github.com/apache/camel/pull/29073

   Fixes [CAMEL-26231](https://issues.apache.org/jira/browse/CAMEL-26231), 
found while adding the catalog body types (CAMEL-24961).
   
   ## 1. A server error in the QueryResult does not fail the exchange
   
   **Was:** the producer set the `QueryResult` as the body without looking at 
it. InfluxDB answers a query it cannot run (for example on a database that does 
not exist) with the error inside the result and status 200, so the client 
returns it and the exchange completed as if the query had succeeded, while a 
syntax error (status 400) made the client throw.
   
   **Now:** an error in the `QueryResult`, or in the result of one of its 
statements, fails the exchange with a `CamelInfluxDbException` whose message is 
`The query failed in InfluxDB: ` followed by the error text of the server. A 
result without error is the body as before.
   
   ## 2. The Map converter mutates the caller's Map
   
   **Was:** the converter removed `camelInfluxDB.MeasurementName` from the body 
Map and put it back, so an immutable Map failed with 
`UnsupportedOperationException`, and a Map shared with other code was changed 
while the point was built.
   
   **Now:** the fields are a copy of the Map without the measurement key; the 
Map of the caller is not touched.
   
   ## 3. The operation is a case-sensitive free String
   
   **Was:** `operation` was a free String compared case-sensitively, so 
`operation=QUERY` was accepted and every message failed with "The operation 
QUERY is not supported", and a misspelled operation was only found at the first 
message.
   
   **Now:** the option declares `enums = "insert,query,ping"` and is compared 
ignoring case, so `operation=QUERY` runs a query and lower-case values work as 
before. An endpoint with another value fails to start with "The operation X is 
not supported: use one of insert, query or ping". The option description now 
lists ping and says the value is not case-sensitive.
   
   ## Tests
   
   `InfluxDbProducerQueryErrorTest` uses the mocked `InfluxDB` client of the 
module and a query route:
   
   - The answer of InfluxDB to a query on an unknown database (the error in the 
result of the statement) fails the exchange with `The query failed in InfluxDB: 
database not found: myTestTimeSeries`, and the next step gets nothing.
   - An error on the `QueryResult` itself, and an error in the second statement 
after a first one that succeeded, fail the same way.
   - A result without error is still the body.
   
   `InfluxDbProducerOperationTest` adds a route per operation value: 
`operation=QUERY` runs the query and gives its `QueryResult`, `operation=Ping` 
gives the `Pong`, `operation=INSERT` writes the point, and `operation=delete` 
makes the route fail to start with the `IllegalArgumentException` and its 
message.
   
   `CamelInfluxDbConverterTest` converts a `Map.of` body, and checks that a 
`LinkedHashMap` keeps its entries and their order.
   
   Revert check: with the change to `src/main/java` reverted, 9 of the 10 new 
tests fail: the operation tests with "The operation QUERY is not supported" 
(and Ping, INSERT) on the first message, and with a route that starts with 
`operation=delete`; the query error tests because the exchange completes with 
the `QueryResult` as the body; the Map tests with 
`UnsupportedOperationException` and the reordered keys. The one that passes is 
the result without error, which checks behaviour that does not change.
   
   Module: 22 tests, 0 failures (12 before).
   
   ## Docs and generated files
   
   - `influxdb-component.adoc`: an Operations section (values, case, startup 
check, query errors) and a sentence saying the Map body is not changed. The 
catalog copy of the doc is updated.
   - The `operation` option gets its enum values and a new description, and the 
`@BodyTypes` output description now says a query error fails the exchange: the 
component JSON and its catalog copy are regenerated. The endpoint DSL has to be 
regenerated for the option change.
   - Upgrade guide entry for 4.24: the query error failure and the operation 
check at startup.
   
   ## Not changed
   
   - The operation stays a String option (with enum values) rather than a Java 
enum, so the endpoint API and the `InfluxDbOperations` constants are unchanged.
   - `checkDatabaseExistence` / `autoCreateDatabase` still ignore an error in 
the result of `SHOW DATABASES` or `CREATE DATABASE`; that path is not part of 
the issue.
   - On a query error the message body is left as it was before the query; the 
error text is in the exception.
   
   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]

Reply via email to