[
https://issues.apache.org/jira/browse/CAMEL-26224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26224 started by Andrea Cosentino.
------------------------------------------------
> camel-couchdb - a couchdb consumer feeding a couchdb producer never saves:
> the producer reads the consumer's CamelCouchDbMethod=UPDATE header and does
> nothing
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26224
> URL: https://issues.apache.org/jira/browse/CAMEL-26224
> Project: Camel
> Issue Type: Bug
> Components: camel-couchdb
> Reporter: Claus Ibsen
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of couchdb (CAMEL-24961, PR #28398).
> h4. 1. The consumer's method header makes the producer do nothing
> {{CouchDbConsumer}} (main 2a465aa4814c, line 70) sets {{CamelCouchDbMethod}}
> to {{UPDATE}} or {{DELETE}} on each change. {{CouchDbProducer.process}} (line
> 49) reads the same header as its operation: it saves only when the header is
> empty (line 50), and handles only {{DELETE}} (line 62) and {{GET}} (line 74).
> Any other value, such as the consumer's {{UPDATE}}, falls through both
> checks, so the exchange succeeds and nothing is written. A route {{couchdb:a
> -> couchdb:b}} never saves a document. Checked on 4.24.0-SNAPSHOT with
> CouchDB from test-infra (docker).
> Proposed: treat {{UPDATE}} (and any value other than GET and DELETE) as a
> save, or fail on an unknown method instead of doing nothing.
> h4. 2. GET needs a valid JSON body it does not use
> {{process}} (line 48) parses the body with {{getBodyAsJsonElement}} before it
> looks at the operation, so a GET with no body fails with
> {{InvalidPayloadException}} although GET only reads the {{CamelCouchDbId}}
> header (line 75). Checked on 4.24.0-SNAPSHOT with CouchDB from test-infra
> (docker).
> Proposed: parse the body only for save and delete.
> h4. 3. Invalid JSON text gives a confusing error
> {{getBodyAsJsonElement}} (line 96) catches the {{JsonSyntaxException}} and
> throws {{new InvalidPayloadException(exchange, body.getClass())}}, so the
> message is "No body available of type: java.lang.String but has type:
> java.lang.String" and the parse error is dropped. Checked on 4.24.0-SNAPSHOT
> with CouchDB from test-infra (docker).
> Proposed: keep the {{JsonSyntaxException}} as the cause and say the body is
> not valid JSON.
> h4. 4. A JSON array fails with "Could not save document [unknown reason]"
> {{saveJsonElement}} (line 109) only handles a {{JsonObject}} and returns null
> for an array, so {{process}} throws {{CouchDbException("Could not save
> document [unknown reason]")}} (line 53). Checked on 4.24.0-SNAPSHOT with
> CouchDB from test-infra (docker).
> Proposed: fail with a clear message that the body must be one JSON object (or
> save each element of an array).
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)