Andrea Cosentino created CAMEL-26637:
----------------------------------------

             Summary: camel-azure-cosmosdb - createContainer does not normalize 
the partition key path
                 Key: CAMEL-26637
                 URL: https://issues.apache.org/jira/browse/CAMEL-26637
             Project: Camel
          Issue Type: Bug
          Components: camel-azure
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.24.0


{{CosmosDbDatabaseOperations.createContainer}} adds the leading {{/}} to the 
partition key path when it is missing (its comment says that the path must 
start with {{/}}), but it uses the normalized path only when an indexing policy 
is set. Without one, it passes the path as it was given to 
{{createContainerIfNotExists}}:

{code:java}
} else {
    return applyToDatabase(database -> 
database.createContainerIfNotExists(containerId, containerPartitionKeyPath,
            throughputProperties));
}
{code}

So the {{createContainer}} operation, and the producer and the consumer that 
create their container ({{createContainerIfNotExists=true}}), send a path such 
as {{partition}} instead of {{/partition}}, as with the examples of the 
component documentation 
({{.setHeader("CamelAzureCosmosDbContainerPartitionKeyPath", 
constant("partition"))}}).

It is a regression of CAMEL-19902 (4.1.0), which added the indexing policy: 
before it, the normalized path was always passed. Found while running the 
integration tests on Floci AZ (CAMEL-26616), which keeps the path as given and 
then refuses every item write: {{400 Invalid input: JSON Pointer expression 
must start with '/': "partition"}}.

*Fix:* pass the normalized path in both branches, and make 
{{CosmosDbDatabaseOperationsTest.testCreateContainer}} check the path given to 
the SDK (it only checked the mocked response).

_Claude Code on behalf of Andrea Cosentino_



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

Reply via email to