davsclaus opened a new pull request, #28449: URL: https://github.com/apache/camel/pull/28449
## What [CAMEL-25928](https://issues.apache.org/jira/browse/CAMEL-25928), a small item of the EIP body types: the data type transformers get body types, and `transformDataType` takes its body from the transformer of its `toType`, instead of `unknown`. Stacked on #28448. ### The sides - **`@BodyTypes`** has two new sides, `transformerIn` (the bodies the transformer can transform) and `transformerOut` (the body after it). `GenerateDataTypeTransformerMojo` writes them into the transformer JSON. The catalog API (`TransformerModel`, `JsonMapper`) and the build checks of `BodyTypesHelper` know them. - **`transformDataType`** gets `eipIn` from `transformerIn` and `eipOut` from `transformerOut`. - **The YAML validator** finds the transformer of `toType` by the name Camel resolves it with (`TransformerResolver`): it drops `camel:`, turns `: _ . / \` into `-`, and lowercases. So `aws2-s3:application-cloudevents` and `text/plain` both work. - It walks on with the body the transformer leaves. - It reports a body the transformer cannot take, for example parsed data before `application-octet-stream`. - **Docs:** the Message Body Types page has a section on data type transformers, and the website's Message Body table has labels for the new sides. The AI tools' `camel_catalog_doc` text has them as well. - **Generator fix:** `GenerateDataTypeTransformerMojo` read the attributes `from` and `to`, but the annotation names them `fromType` and `toType`. The catalog never had them; it reads them now. No transformer sets them today. ### All 47 transformers (56 classes with camel-jackson3) Each declaration comes from reading `transform()`, and is **proven by a runtime test** in its module. A `theBodyTypesSayTheBody` method checks the declared sides, runs the transformer on the bodies `transformerIn` allows, and checks the body after. Where a body is kept, the test checks it is the same instance. Where a body is not allowed, the test shows it failing. | Group | In → out | |---|---| | core `text-plain`, `application-octet-stream` | any → text; text, bytes, a stream or a file → bytes. A number fails, as the test showed. | | 20 `*:application-cloudevents` of the components | any → unchanged: they set headers only. Calendar needs its `Event`. | | `application-cloudevents+json` | any → text as json, or unchanged when the body is a JSON CloudEvent already | | jackson `application-json` / `avro-binary` / `protobuf-binary` | JSON text or an object → `byte[]` (json / binary) | | jackson `*-x-java-object` | a payload or an object → unknown (the content class) | | jackson `*-x-struct` | a payload or an object → `JsonNode` (jackson 2 / jackson 3 class) | | `*:embeddings` (vector DBs) | the text segment, with the vector from a header → the write object of the store | | `*:rag` (vector DBs) | the List of search results → `List<String>` | | aws2-ddb, google-mail, google-sheets | per transformer, see the javadoc of each | ## Tests - Runtime: a `theBodyTypesSayTheBody` test for every transformer in 34 modules, all passing. - 23 test classes are new: most CloudEvent transformers had none. - The others were extended. - `BodyTypesHelperEipTest`: 9 tests (transformer sides, `transformDataType` from them). `JsonMapperTest`: 13, including the round trip of the transformer body types. `GenerateDataTypeTransformerMojoTest` (new) reads `fromType` and `toType`. - Validator: 308 tests. The new `transformDataType` tests fail on the old code. They cover: - text after `text-plain`; - an unknown transformer; - a CloudEvent transformer that keeps the parsed body; - parsed data before `application-octet-stream`. - jackson-core AI tests: 741 pass. ## Found on the way, not fixed here The runtime tests showed behaviour that looks like bugs. The declarations describe what the code does today: - `google-calendar-stream:application-cloudevents` throws a NullPointerException on any body that is not a calendar `Event`. - jackson `application-json` rejects a Map, a List, plain text or bytes without a content class, because it writes with root type `JsonNode`. - jackson `*-x-java-object` throws a NullPointerException on a null body when `X-Content-Class` is set. - jackson 2 `avro-x-java-object` and `protobuf-x-java-object` fail on a `JsonNode` body. Jackson 3 handles it. - jackson3 avro and protobuf let `JacksonException` through unwrapped, where jackson 2 wraps it in `CamelExecutionException`. - `avro-x-struct` does not take JSON text, but `protobuf-x-struct` does. - `pinecone:rag` gives an empty List for the `QueryResponseWithUnsignedIndices` a Pinecone query leaves. `pinecone:embeddings` stores no text, so `pinecone:rag` reads `""`. - `aws2-sqs:application-cloudevents` builds the CloudEvent source from the receipt handle, not the queue name. - `aws2-ddb:application-x-struct` says "into a Json node" but leaves a JSON String. It fails on a stream or a file (Gson on Java 21). - Milvus, Neo4j, Qdrant, Pinecone and Weaviate throw a bare NullPointerException when the embedding header is missing. _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]
