Azure / Azure/azure-sdk-for-rust
Support /id completion for hierarchical partition keys
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 112
Description
## Description
Add SDK-side completion for item-addressing partition keys when a container's partition key definition ends with `/id`.
For a hierarchical partition key such as `["/tenantId", "/id"]`, callers should be able to provide only the prefix (`tenantId`) for point operations. The SDK should append the addressed item's ID before routing and sending the request. Fully specified partition keys must remain unchanged.
This provides parity with:
- Java: https://github.com/Azure/azure-sdk-for-java/pull/49709
- .NET: https://github.com/Azure/azure-cosmos-dotnet-v3/pull/5600
## Current Rust behavior
The Rust SDK forwards point-operation partition keys unchanged. Its HPK emulator coverage explicitly expects a partial-key point read to fail with `400 Bad Request` and substatus `1001 PartitionKeyMismatch`.
Relevant code:
- `sdk/cosmos/azure_data_cosmos/src/clients/container_client.rs`
- `sdk/cosmos/azure_data_cosmos/tests/emulator_tests/cosmos_hpk.rs`
- `sdk/cosmos/azure_data_cosmos_driver/src/driver/pipeline/operation_pipeline.rs`
## Expected behavior
- Complete an eligible prefix when the container's final partition key path is exactly `/id`.
- Support item point operations: create, read, replace, upsert, delete, and patch.
- Use the addressed item ID for replace rather than an ID from the replacement body.
- Preserve fully specified partition keys.
- Do not rewrite unrelated partial keys or partition key definitions not ending in `/id`.
- Continue requiring a full partition key for transactional batches.
- Keep prefix semantics unchanged for queries, feeds, and change feed operations.
- Add unit and emulator coverage for HPK `[/tenantId, /id]` and single-path `/id` containers.
The current Rust item APIs already receive `item_id` separately, including create and upsert, so completion should not require extracting the ID from the serialized item body.
Contributor guide
Research direction
Start by tracing point-operation partition-key handling in sdk/cosmos/azure_data_cosmos/src/clients/container_client.rs and sdk/cosmos/azure_data_cosmos_driver/src/driver/pipeline/operation_pipeline.rs. Run the existing HPK cases in sdk/cosmos/azure_data_cosmos/tests/emulator_tests/cosmos_hpk.rs, then add unit and emulator coverage for eligible /id completion and single-path /id containers. Done means item operations accept eligible prefixes while full keys, unrelated definitions, batches, queries, feeds, and change feeds retain their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, rust
- Domain
- api, backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100