Claus Ibsen created CAMEL-26119:
-----------------------------------

             Summary: camel-camunda - a JSON body as bytes or a stream is 
rejected as data missing, and a failed operation does not fail the exchange
                 Key: CAMEL-26119
                 URL: https://issues.apache.org/jira/browse/CAMEL-26119
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of flowable, camunda and bonita 
(CAMEL-24961, PR #28418).

h4. 1. A JSON body as bytes or a stream is rejected

The producer processors accept JSON only when the body is a {{String}}: 
{{ProcessProcessor}} (main 2a465aa4814c, lines 43 and 52), {{JobProcessor}} 
(lines 44 and 58) and {{MessageProcessor}} (lines 39 and 47) check {{instanceof 
String}} and else throw "Process data missing" ("Job data missing", "Message 
data missing"). A JSON body as {{byte[]}} or an {{InputStream}}, as an HTTP 
consumer gives, is rejected although it converts to a String. Checked on 
4.24.0-SNAPSHOT with a mocked {{CamundaService}}.

Proposed: convert any other body to a String (when it can be) before parsing it 
as JSON.

h4. 2. The consumer's JSON uses other property names than the producer's

With {{formatJSON=true}} the consumer writes the {{JobWorkerMessage}} as JSON 
in camelCase with a {{variablesAsMap}} field ({{JobWorkerMessage}}, main 
2a465aa4814c, line 42; {{CamundaConsumer}} line 106), while the producer reads 
and writes snake_case JSON ({{ProcessRequest}} line 32, {{process_id}}). So the 
JSON of a consumer cannot be sent to a producer as is. Checked on 
4.24.0-SNAPSHOT with a mocked {{CamundaService}}.

Proposed: use the same naming (snake_case, as documented) for the consumer's 
JSON.

h4. 3. A failed operation does not fail the exchange

{{CamundaService}} catches every exception of the Camunda client (main 
2a465aa4814c, e.g. lines 85-89 for startProcess) and returns a response with 
{{success=false}} and the error message, so the exchange completes normally and 
the route goes on as if the operation had worked. Checked on 4.24.0-SNAPSHOT 
with a mocked {{CamundaService}}.

Proposed: set the exception on the exchange when the operation fails (keeping 
the response in the body), or at least document that the 
{{CamelCamundaIsSuccess}} header must be checked.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to