Claus Ibsen created CAMEL-26166:
-----------------------------------

             Summary: camel-stripe - a bytes or stream body is not converted to 
the request parameters, and the CamelStripeOperation header is never read
                 Key: CAMEL-26166
                 URL: https://issues.apache.org/jira/browse/CAMEL-26166
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of stripe (CAMEL-24961, PR #28410).

h4. 1. A bytes or stream body is not converted

{{StripeProducer.getParametersFromBody}} (main 2a465aa4814c, lines 76-99) 
accepts only a {{Map}} or a {{String}} (by {{instanceof}}) and throws "Body 
must be a Map<String, Object> or a JSON String" for anything else. A JSON body 
as {{byte[]}} or {{InputStream}}, e.g. the body of a {{rest:post}} or 
{{platform-http}} route, fails. Checked on 4.24.0-SNAPSHOT with a local JDK 
HttpServer as {{apiBase}}: the REST example in the doc failed until a 
{{convertBodyTo}} String was added (done in the PR).

Proposed: convert any other body with {{getBody(String.class)}} before parsing 
it as JSON.

h4. 2. The CamelStripeOperation header is declared and documented but never read

{{StripeConstants.OPERATION_HEADER}} (main 2a465aa4814c, lines 38-39) is listed 
in the docs as a header ("The operation to perform"), but 
{{StripeProducer.process}} (line 55) takes the operation only from the endpoint 
option, so the header has no effect. Checked on 4.24.0-SNAPSHOT with the local 
fake.

Proposed: read the header first and fall back to the {{operation}} option (as 
is done for {{CamelStripeMethod}}), or remove the header from the docs.

h4. 3. update, capture, delete and cancel make an extra retrieve GET first

{{StripeProducer}} handles update, capture, delete and cancel by retrieving the 
object first and then calling the method on it (main 2a465aa4814c, e.g. lines 
138, 144, 160 and 164, and the same for the other operations), so each call 
makes two HTTP requests to Stripe. Checked on 4.24.0-SNAPSHOT with the local 
fake, which received a GET before each update and delete.

Proposed: call the Stripe API on the id directly (for example the 
{{StripeClient}} service API, {{client.customers().update(id, params)}}), 
without the retrieve.

_Claude Code on behalf of davsclaus_



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

Reply via email to