Repository navigation
CAMEL-24961: Catalog body types for object storage - #28251
Conversation
…s, and the body it leaves after a step A @BodyTypes annotation on the endpoint, data format or language class says the body per side (consumerOut, consumerReply, producerIn, producerOut, marshal, unmarshal and expression in and out): its carriers (null, text, bytes, stream, file, value, map, list, pojo, unchanged, any, unknown), the Java type when it is always the same, the format, the options it depends on, the body for other option values, and a description. The package plugin writes it as a bodyTypes section of the catalog JSON and checks that each side fits the kind and that the options it names exist. A subclass declares its own. The first slice: file, direct, seda, timer, cron, kamelet, http, https, rest-openapi, xslt, sql and the json data format (jackson), read from the code that sets the body and checked against the body types the message history records when routes run. camel_catalog_doc returns them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…tp, jms, kafka, aws2-sqs, the csv, jacksonXml and yaml data formats, and the languages The second slice of the catalog body types: - components: platform-http, rest (and the rest-openapi consumer), ftp, ftps, sftp, jms, activemq, activemq6, amqp, kafka, aws2-sqs, log, mock, scheduler, quartz; - data formats: csv, jacksonXml, snakeYaml; - languages: simple, constant, jsonpath, xpath, groovy, jq. Each value is read from the code that sets the body, and checked against the body types the message history recorded when the tests of the modules and reference routes ran (the ftp integration tests included). camel_catalog_doc gives the body types a line per side, and its answer is cut at 18000 characters instead of 16000, so the four sides of the jms components leave the options a limit asks for room. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
paho-mqtt5: the consumer gives the payload as a byte array, the producer sends what converts to one and leaves the body unchanged. mongodb: the consumer gives a Document (or null for a change without its full document with changeStreams); the producer takes a document or a query, and leaves a body by operation: a Document or null for a find of one, a List for findAll, findDistinct and aggregate, a Long for count, the result of the driver for the other writes. Read from the code that sets the body, and checked against a mosquitto and a mongodb container started with camel infra. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…ts an option value without carriers
From the review of PR 28241:
- An iterator is read once and has no size and no index, so tooling that
reads list as a List accepts ${body.size()} or ${body[0]} on it, which fail
at runtime. The new iterator carrier names it: sql with outputType=StreamList
gives an iterator, not a list.
- A @BodyType.When with no carriers (carrier = {}) wrote "carriers": [] into
the catalog. The build now rejects it, as it does a side without carriers.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…MEL-24961-catalog-body-types-2 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
… camel_catalog_doc says unknown for no carriers From the review of PR 28242: - The csv data format with lazyLoad=true gives an iterator, with the iterator carrier of PR 28241, not a list. - camel_catalog_doc says unknown for a body without carriers, instead of failing. The build rejects it now, but a catalog read from elsewhere may have one. - Sqs2Endpoint imports org.apache.camel.spi.* already: only the import of the nested BodyType.Carrier stays. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…types of the catalog instead of their own tables The YAML validator's body walks read what a component or a data format does with the body from the catalog, instead of from tables in their source: - the consumer a route starts with (consumerOut): the file as read, text, bytes or data, instead of the file consumer only; - the body after a to: (producerOut): unchanged for log and mock and now for a file write, the response of the http producer as bytes or a stream; - the producers that need text (producerIn), instead of file, ftp, ftps and sftp only; - the body after an unmarshal (unmarshalOut), instead of the json, jacksonXml, yaml and csv table and the options that make something else; - the consumers that reply with text (consumerReply), instead of platform-http; - the consumers that give no body, instead of timer, quartz, scheduler and cron. A side holds for a step only when the step decides every option it depends on: an option the component can also be configured with (the valueDeserializer of kafka) counts only when the endpoint sets it, and a placeholder value is not known. The catalog of an older Camel version has no body types, so the validator's own catalog stands in for it. After a step that fails at runtime the walk stops, so a file write that keeps the body is reported once. The rules about HTTP methods, REST bindings and EIPs stay in the validator; the EIPs get body types with CAMEL-25928. The same reports as before on 1204 human-written route files (the Camel repository, the examples, kamelets, camel-k and camel-kit) and on 1209 model-written ones (the r17 benchmark series), and the doc examples of the validator tests still validate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…docling, milvus, qdrant, ai-tool and ibm-watson-language The AI components declare the body they need and the body they leave, per operation where the operation decides it. The answer of openai and langchain4j-chat is text, also when it is asked for JSON, so the YAML validator now reports a field read on it that has no unmarshal before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
… endpoint count for its body types The operation of openai is in the path (openai:embeddings), so the validator reads the path options with the syntax of the component, as the catalog parses an endpoint. A path the catalog cannot read, such as a toD with an expression, says nothing about its options. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…pe for a value its option cannot have A byOption value must be one of the enum of its option, or true or false for a boolean, ignoring case as tooling compares it with the endpoint: a misspelled operation such as embedding for embeddings would never hold. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
The attribute holds an array, and the catalog JSON and BodyTypeModel call the same field carriers. The Javadoc of BodyTypeModel.isUnknown() says that a side with no carriers is unknown too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…MEL-24961-catalog-body-types-2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…AMEL-24961-catalog-body-types-3
…AMEL-24961-catalog-body-types-ai # Conflicts: # tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/BodyTypesHelper.java
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
The body types of aws2-s3, azure-storage-blob, azure-files, dropbox, google-storage, ibm-cos and minio, read from the code and checked at runtime against LocalStack S3 (aws2-s3, and ibm-cos and minio through their S3 API) and Azurite (azure-storage-blob). The pages of aws2-s3, google-storage and minio said getObject returns an S3Object, a Blob or a MinioObject: it returns the content of the object. The validator calls a body the file as read (a GenericFile) only when the file is its only carrier, not for a blob that is a stream or a file. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet-bot
left a comment
There was a problem hiding this comment.
LGTM. The @BodyTypes annotations are consistent across all 7 components, the runtime-verified descriptions match the catalog JSON, and the file() method fix (exact-list equality vs. contains) is correct and intentional. Docs fixes for getObject return types are accurate.
One behavior-doc note for awareness: the aws2-s3-consumer-examples.adoc previously stated includeBody=false gives "only metadata" — the new wording correctly says it gives the stream of the object (and points to ignoreBody=true for metadata-only). No action needed.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…e data format and language schemas Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…-types' into feature/CAMEL-24961-catalog-body-types-2
…AMEL-24961-catalog-body-types-3
…AMEL-24961-catalog-body-types-ai
…AMEL-24961-catalog-body-types-storage
…n read as a list, as the carriers do Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…AMEL-24961-catalog-body-types-3
…AMEL-24961-catalog-body-types-ai
…AMEL-24961-catalog-body-types-storage
…atalog-body-types-3 Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…AMEL-24961-catalog-body-types-ai
…atalog-body-types-ai # Conflicts: # docs/user-manual/modules/ROOT/pages/camel-jbang-validation.adoc # dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/CatalogBodyTypes.java # dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java
…AMEL-24961-catalog-body-types-storage
…atalog-body-types-storage # Conflicts: # dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/TextBodyFlowTest.java
Stacked on #28250. This is the object storage group of the catalog body types (CAMEL-24961): aws2-s3, azure-storage-blob, dropbox, google-storage, ibm-cos, minio and azure-files. Of the components the human-written routes use, these are the storage ones used most: 17, 12, 8, 6, 6, 4 and 4 times.
What the catalog says now
bytes; astreamwith includeBody=false, no body with ignoreBody=truetext,bytes,streamorfileunchangedafter an upload. By operation: getObject astream, the lists alist, the linkstext, deleteObjecttrue, the SDK response for the othersstream, or with fileDir thefileany. The uploads taketext,bytes,streamorfile, the block lists alistlistfor listBlobContainers (the default) and the other lists. getBlob astream, downloadBlobToFile afile,truefor the writesmapfor a folder. search: alistany: localPath or a header can name the file to uploadlistfilewith downloadFileName, the Blob with includeBody=falsebytes, the lists alist, the deletestrueorfalsestream; no body with includeBody=falseunchangedafter putObject. getObject astream, the lists alist, headBucket a Booleanbytes; no body with includeBody=falseunchangedafter an upload. getObject astream, listObjects an Iterable and listBuckets an Iterator:iteratorfileas read, as for ftptext,bytes,streamorfileunchangedIn every one of them, an upload of a Map or a List fails rather than sending its toString(). It is an InvalidPayloadException, or an IllegalArgumentException in azure-storage-blob. The descriptions say to marshal it first.
Checked at runtime. Routes logged the class of the body after each step, against
camel infra run aws(S3 on LocalStack) andcamel infra run azure(Azurite):With stream caching on, the next step after getObject sees the stream cache, not the SDK's ResponseInputStream.
AmazonS3client bean with HMAC keys, and minio through its endpoint option. The image ofcamel infra run minioneeds a login on quay.io now.Options the component can set. In aws2-s3, azure-storage-blob, google-storage, ibm-cos and minio, every option is a component option too, as the component shares its configuration. The validator counts a component option only when the endpoint sets it. So it checks a step only when the endpoint names the operation: after
aws2-s3:reports?operation=getObjectthe body is a stream, andaws2-s3:reportssays nothing. At runtime the operation header (such as CamelAwsS3Operation) wins over the option, as it does for aws2-sqs.One validator change. The validator called a body "the file as it was read (a GenericFile)" whenever
filewas one of its carriers. Now that wording, and the file properties such as${body.fileName}, apply only when the file is the only carrier. A blob that is a stream or a downloaded file is a payload like any other. Before this group, no side in the catalog mixedfilewith another payload carrier.Docs. The pages of aws2-s3, google-storage and minio said getObject returns an S3Object, a Blob or a MinioObject instance. It returns the content of the object. The aws2-s3 consumer example said includeBody=false gives only the metadata. It gives the stream, and ignoreBody=true gives the metadata only.
Measured. I ran the validator over the 1204 human-written and 1209 model-written route files, and the reports are the same as with #28250. The human files use these components 57 times. Most are Kamelets that pass the body to kamelet:sink, or uploads, or getObject through toD.
Tests
TextBodyFlowTest.testTheBodyOfObjectStoragecovers four routes:Claude Code on behalf of davsclaus
🤖 Generated with Claude Code