Repository navigation
Add partition-key scoping and ETag support to rm - #230
Conversation
Adds --partition-key/--pk to restrict rm previews and deletions to one complete logical partition, uses point read/delete for exact ids, and adds --etag enforced via IfMatchEtag for single-item deletes. Fixes #229 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Numeric partition keys at the 64-bit upper boundary can be corrupted in result serialization.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds partition-key scoping and conditional ETag deletion to rm.
Changes:
- Adds scoped point reads/deletes and ETag validation.
- Updates help, localization, and documentation.
- Adds unit, MCP, and emulator coverage.
| File | Description |
|---|---|
README.md |
Documents safe deletion. |
l10n/CosmosDBShell.json |
Updates localization catalog. |
docs/mcp.md |
Documents MCP workflow. |
docs/commands.md |
Documents new options. |
CosmosDBShell/lang/en.ftl |
Adds localized messages. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/RmCommand.cs |
Implements scoped and conditional deletion. |
CosmosDBShell.Tests/ToolOperationsTests.cs |
Tests MCP schema. |
CosmosDBShell.Tests/ToolOperationsCallToolTests.cs |
Tests confirmation rendering. |
CosmosDBShell.Tests/Integration/RmPartitionKeyETagTests.cs |
Tests emulator behavior. |
CosmosDBShell.Tests/CommandTests/RmCommandTests.cs |
Tests parsing and validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall line coverage in commit a1fa6c5 in the Show a line coverage summary of the most impacted files.
Updated |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Linux emulator does not distinguish numeric and string partition key values, so the typed-key distinction stays covered by unit tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation satisfies the safety requirements and includes comprehensive documentation, localization, unit, MCP, and emulator coverage.
Review effort: Balanced
Findings: None



Fixes #229
Adds two optional arguments to
rm:--partition-key/--pkrestricts both the dry run and the deletion to one complete logical partition key. It uses the same typed and hierarchical parsing aspatchandbatch. Incomplete hierarchical keys are rejected, and piped items outside the partition are skipped.--etagdeletes a single item only if its current ETag matches, enforced server-side throughIfMatchEtag. A mismatch is reported as a failed precondition and is not retried.For
rm <id> --key=id --partition-key=<pk>, the command uses a point read (dry run) or point delete against(id, partitionKey)instead of scanning the container. The exact-item dry run keepscountand addsid,partitionKey, andetag.--etagis rejected before any deletion for wildcard patterns, piped input, missing--key=id, empty values, or a missing--partition-key. MCP confirmation shows the partition key and ETag in the command presented for approval. Behavior is unchanged when the new options are omitted.Help text, MCP tool schemas,
docs/commands.md,docs/mcp.md, and the README are updated, with unit, MCP, and emulator integration tests.