Claus Ibsen created CAMEL-26246:
-----------------------------------

             Summary: camel-azure-cosmosdb - a JSON text body for createItem, 
upsertItem and replaceItem is stored as a JSON string and fails, and a List 
body has no bulk operation
                 Key: CAMEL-26246
                 URL: https://issues.apache.org/jira/browse/CAMEL-26246
             Project: Camel
          Issue Type: Bug
          Components: camel-azure
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of azure-cosmosdb (CAMEL-24961, PR 
#28403).

h4. 1. A JSON text body is sent as a JSON string

{{CosmosDbConfigurationOptionsProxy.getItem}} (main 2a465aa4814c, line 103) 
passes the body as it is to {{createItem}}, {{upsertItem}} and {{replaceItem}} 
({{CosmosDbProducer}}, lines 241, 252, 275). The SDK serializes a String as a 
JSON string, so a JSON text body (what an HTTP or file consumer gives) fails 
with 400 "Document does not contain an id field". Checked on 4.24.0-SNAPSHOT 
with the Cosmos DB vnext emulator in docker.

Proposed: parse a String (and byte[]) body as a JSON document (e.g. to a Map or 
{{ObjectNode}}) before the item operations.

h4. 2. A List body cannot be written: createItems and upsertItems are never used

{{CosmosDbConfigurationOptionsProxy.getItems}} (line 106) handles a List body 
and {{CosmosDbContainerOperations}} has {{createItems}} and {{upsertItems}} 
(lines 89 and 105), but no producer operation calls them; createItem with a 
List body fails with 400. Checked on 4.24.0-SNAPSHOT with the emulator.

Proposed: either add bulk operations that use them, or remove the unused code.

h4. 3. A stream body fails and a File body is stored as its path

With an {{InputStream}} body the SDK's Jackson fails "No serializer found for 
class ByteArrayInputStreamCache"; a {{File}} body is serialized as its path. 
Checked on 4.24.0-SNAPSHOT with the emulator.

Proposed: read stream, File and GenericFile bodies as JSON content, the same as 
text.

_Claude Code on behalf of davsclaus_



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

Reply via email to