You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/10/04 10:33:49 UTC
[PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
davsclaus opened a new pull request, #27331:
URL: https://github.com/apache/camel/pull/27331
[CAMEL-25309](https://issues.apache.org/jira/browse/CAMEL-25309)
**The problem:** a Map or List body sent with the HTTP producer fails like this:
```
InvalidPayloadException: No body available of type: java.io.InputStream but has type: java.util.LinkedHashMap on: order-1001.json. Caused by: No type converter available ...
```
The message names the conversion, not what to do. The body is typically a Map after `unmarshal: json`, for example on a rest-openapi call to a JSON operation, which goes through camel-http. In the local-model benchmark (contracts/openapi-client), 3 of 5 runs failed on it.
**The change:**
- In `HttpProducer.createRequestEntity`, when a Map or Collection body cannot become a stream, the `InvalidPayloadException` keeps its type and uses the existing hint constructor to add: "a Map is not an HTTP request body: marshal it to JSON first (marshal: json) or set the body to the JSON text". A List gets the same with "List".
- The converter's exception is kept as the cause.
- Any other body type fails exactly as before.
**Tests:**
- New `HttpProducerMapBodyTest`: a LinkedHashMap body and a List body each get the hint.
- The camel-http suite passes: 259 tests plus 9 isolated.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27331:
URL: https://github.com/apache/camel/pull/27331#issuecomment-5979070066
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #27331:
URL: https://github.com/apache/camel/pull/27331#discussion_r4177139002
##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java:
##########
@@ -713,6 +715,28 @@ private boolean isCreateNewURL(Exchange exchange) {
return create;
}
+ /**
+ * The body as a stream for the request entity. A Map or a List (a body unmarshalled from JSON, or built as a map)
+ * cannot become one, and the converter's message only names the conversion: say what to do (CAMEL-25309).
+ */
+ private static InputStream mandatoryBodyStream(Exchange exchange, Message in) throws InvalidPayloadException {
+ try {
+ return in.getMandatoryBody(InputStream.class);
+ } catch (InvalidPayloadException e) {
+ Object body = in.getBody();
+ if (body instanceof Map || body instanceof Collection) {
+ InvalidPayloadException answer = new InvalidPayloadException(
+ exchange, InputStream.class, in,
+ "a " + (body instanceof Map ? "Map" : "List")
+ + " is not an HTTP request body: marshal it to JSON first "
Review Comment:
💡 **Nit:** `Collection` covers `List`, `Set`, `Queue`, etc., but the hint always says "List" for any non-Map Collection. A `Set` body (unlikely but possible) would get "a List is not an HTTP request body" — slightly misleading.
Since the realistic scenario after `unmarshal: json` is always `List`, this is cosmetic, but a precise label is easy:
```suggestion
"a " + (body instanceof Map ? "Map" : body instanceof List ? "List" : "Collection")
```
This would require importing `java.util.List` (already indirectly available). Not blocking — the current message is good enough for the 99% case.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27331:
URL: https://github.com/apache/camel/pull/27331#issuecomment-5979179834
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `components/camel-http`
> :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the `test-dependents` label to force testing all dependents.
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 74 of 698 tested, 27 compile-only — current: 74 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **74 affected modules** (current approach: 74).
**Skip-tests mode would test 74 modules** (1 direct + 73 downstream), **skip tests for 27** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (74)</summary>
- `camel-a2a` ← downstream of org.apache.camel:camel-vertx-http
- `camel-ai-observability` ← downstream of org.apache.camel:camel-telemetry
- `camel-as2` ← downstream of org.apache.camel:camel-jetty
- `camel-clickup` ← downstream of org.apache.camel:camel-netty-http
- `camel-consul` ← downstream of org.apache.camel:camel-http
- `camel-cxf-rest` ← downstream of org.apache.camel:camel-http
- `camel-cxf-soap` ← downstream of org.apache.camel:camel-http
- `camel-cxf-spring-rest` ← downstream of org.apache.camel:camel-http
- `camel-cxf-spring-soap` ← downstream of org.apache.camel:camel-http
- `camel-cxf-spring-transport` ← downstream of org.apache.camel:camel-cxf-transport
- `camel-cxf-transport` ← downstream of org.apache.camel:camel-undertow
- `camel-graphql` ← downstream of org.apache.camel:camel-http
- `camel-http` ← components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java, components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerMapBodyTest.java
- `camel-java-joor-dsl` ← downstream of org.apache.camel:camel-telegram
- `camel-jbang-mcp` ← downstream of org.apache.camel:camel-yaml-dsl
- `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-route-parser` ← downstream of org.apache.camel:camel-route-parser
- `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-catalog
- `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-yaml-dsl-validator
- `camel-jetty` ← downstream of org.apache.camel:camel-http
- `camel-jsonpath` ← downstream of org.apache.camel:camel-platform-http-vertx
- `camel-kamelet` ← downstream of org.apache.camel:camel-http
- `camel-knative-http` ← downstream of org.apache.camel:camel-http
- `camel-kubernetes` ← downstream of org.apache.camel:camel-http
- `camel-langchain4j-agent` ← downstream of org.apache.camel:camel-telemetry
- `camel-langchain4j-chat` ← downstream of org.apache.camel:camel-telemetry
- `camel-langchain4j-embeddings` ← downstream of org.apache.camel:camel-telemetry
- `camel-langchain4j-embeddingstore` ← downstream of org.apache.camel:camel-langchain4j-embeddings
- `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
- `camel-lra` ← downstream of org.apache.camel:camel-undertow
- `camel-mcp-server` ← downstream of org.apache.camel:camel-platform-http-vertx
- `camel-micrometer-observability` ← downstream of org.apache.camel:camel-undertow
- `camel-micrometer-prometheus` ← downstream of org.apache.camel:camel-platform-http-main
- `camel-netty-http` ← downstream of org.apache.camel:camel-http
- `camel-oauth` ← downstream of org.apache.camel:camel-vertx-http
- `camel-observability-services` ← downstream of org.apache.camel:camel-opentelemetry2
- `camel-odata` ← downstream of org.apache.camel:camel-http
- `camel-openai` ← downstream of org.apache.camel:camel-platform-http-vertx
- `camel-openapi-validator` ← downstream of org.apache.camel:camel-rest-openapi
- `camel-opentelemetry` ← downstream of org.apache.camel:camel-undertow
- `camel-opentelemetry2` ← downstream of org.apache.camel:camel-undertow
- `camel-platform-http` ← downstream of org.apache.camel:camel-http
- `camel-platform-http-jolokia` ← downstream of org.apache.camel:camel-platform-http
- `camel-platform-http-main` ← downstream of org.apache.camel:camel-platform-http-vertx
- `camel-platform-http-vertx` ← downstream of org.apache.camel:camel-http
- `camel-quickfix` ← downstream of org.apache.camel:camel-jetty
- `camel-rest-openapi` ← downstream of org.apache.camel:camel-http
- `camel-rest-postman` ← downstream of org.apache.camel:camel-http
- `camel-restdsl-openapi-plugin` ← downstream of org.apache.camel:camel-jetty
- `camel-sap-netweaver` ← downstream of org.apache.camel:camel-http
- `camel-semantic` ← downstream of org.apache.camel:camel-xml-io-dsl
- `camel-slack` ← downstream of org.apache.camel:camel-undertow
- `camel-soap` ← downstream of org.apache.camel:camel-cxf-soap
- `camel-spring-ai-chat` ← downstream of org.apache.camel:camel-telemetry
- `camel-spring-rabbitmq` ← downstream of org.apache.camel:camel-http
- `camel-state-store` ← downstream of org.apache.camel:camel-test-main-junit5
- `camel-telegram` ← downstream of org.apache.camel:camel-netty-http
- `camel-telemetry` ← downstream of org.apache.camel:camel-undertow
- `camel-telemetry-dev` ← downstream of org.apache.camel:camel-undertow
- `camel-test-main-junit5` ← downstream of org.apache.camel:camel-xml-io-dsl
- `camel-test-main-junit6` ← downstream of org.apache.camel:camel-xml-io-dsl
- `camel-typesafe-ai` ← downstream of org.apache.camel:camel-xml-io-dsl
- `camel-undertow` ← downstream of org.apache.camel:camel-http
- `camel-undertow-spring-security` ← downstream of org.apache.camel:camel-undertow
- `camel-vertx-http` ← downstream of org.apache.camel:camel-http
- `camel-webhook` ← downstream of org.apache.camel:camel-netty-http
- `camel-whatsapp` ← downstream of org.apache.camel:camel-netty-http
- `camel-xml-io-dsl` ← downstream of org.apache.camel:camel-kamelet
- `camel-xml-jaxb-dsl` ← downstream of org.apache.camel:camel-telegram
- `camel-xml-jaxb-dsl-test-definition` ← downstream of org.apache.camel:camel-telegram
- `camel-xml-jaxb-dsl-test-spring` ← downstream of org.apache.camel:camel-telegram
- `camel-yaml-dsl-validator` ← downstream of org.apache.camel:camel-yaml-dsl
- `camel-yaml-dsl-validator-maven-plugin` ← downstream of org.apache.camel:camel-yaml-dsl-validator
- `camel-zookeeper` ← downstream of org.apache.camel:camel-http
</details>
<details><summary>Modules with tests skipped (27)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/37195763915)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #27331:
URL: https://github.com/apache/camel/pull/27331
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25309: camel-http - a Map or List body says to marshal it to JSON first [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27331:
URL: https://github.com/apache/camel/pull/27331#discussion_r4177178626
##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java:
##########
@@ -713,6 +715,28 @@ private boolean isCreateNewURL(Exchange exchange) {
return create;
}
+ /**
+ * The body as a stream for the request entity. A Map or a List (a body unmarshalled from JSON, or built as a map)
+ * cannot become one, and the converter's message only names the conversion: say what to do (CAMEL-25309).
+ */
+ private static InputStream mandatoryBodyStream(Exchange exchange, Message in) throws InvalidPayloadException {
+ try {
+ return in.getMandatoryBody(InputStream.class);
+ } catch (InvalidPayloadException e) {
+ Object body = in.getBody();
+ if (body instanceof Map || body instanceof Collection) {
+ InvalidPayloadException answer = new InvalidPayloadException(
+ exchange, InputStream.class, in,
+ "a " + (body instanceof Map ? "Map" : "List")
+ + " is not an HTTP request body: marshal it to JSON first "
Review Comment:
Applied in 85c987049d95: a Set or other Collection is now named as such, List stays List.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org