Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the Cosmos DB shell’s data-mutation surface by adding item replacement and single-operation patch support, while also extending mkitem with upsert behavior. It fits into the CLI’s command layer by adding new item-level write workflows, corresponding localization/help text, documentation, and integration tests.
Changes:
- Add a new
replacecommand for full-document replacement, including piped/array JSON input and optional ETag handling. - Add a new
patchcommand for single Cosmos patch operations (set,add,replace,remove,incr). - Extend
mkitemwith--force/--upsert, and update docs/localization/tests for the new command surfaces.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
docs/commands.md |
Documents updated mkitem usage and adds reference docs for replace and patch. |
CosmosDBShell/lang/en.ftl |
Adds help text, success strings, and error messages for the new/updated commands. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ReplaceCommand.cs |
Implements full-item replacement logic, including array handling and ETag support. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/PatchCommand.cs |
Implements single-operation patch execution and client-side value parsing/validation. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeItemCommand.cs |
Adds --force/--upsert behavior by switching item creation to upsert when requested. |
CosmosDBShell.Tests/Integration/DataOperationTests.cs |
Adds integration coverage for new replace/patch flows and mkitem --force. |
- Docs: README's feature list and docs/navigation.md's pipe-aware
command table now mention replace and patch.
- HPK numeric components no longer truncate via GetDouble(); use
TryGetInt64 first so 64-bit integer keys above 2^53 are preserved.
- CreatePartitionKeyFromArgument now treats '{...}' as JSON too and
throws JsonException for object-shaped roots so the patch command
surfaces the localized invalid_pk_json error instead of falling
through to a string PartitionKey with the raw text.
- mkitem array mode (force and non-force) now throws CommandException
after the printed summary when failCount > 0, so scripted callers
do not treat partial/total bulk failures as success.
- create database/container with --force/--upsert is now rejected with
command-create-error-force_only_for_items instead of silently
ignoring the flag.
# Conflicts: # CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeContainerCommand.cs
CreatePartitionKeyFromArgument falls back to string PartitionKey for ambiguous scalar literals (e.g. 001, -svc) so existing string keys stay targetable; objects/arrays/quoted strings still surface JsonException. PatchCommand remove rejects any supplied value including empty string. Added unit tests for create container/database with --force.
sevoku
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
replacefor replacing existing Cosmos DB items from JSON argument or piped input, including array input and ETag supportpatchfor single-operation partial item updates withset,add,replace,remove, andincrmkitem --force/--upsertbehavior for create-or-replace workflowsValidation
dotnet build CosmosDBShell/CosmosDBShell.csproj -nologo -p:BaseOutputPath=C:\work\CosmosDBShell\obj\agent-patch-replace-review-build\dotnet test CosmosDBShell.Tests/CosmosDBShell.Tests.csproj -nologo -p:BaseOutputPath=C:\work\CosmosDBShell\obj\agent-patch-replace-review-build\ --filter "FullyQualifiedName~LocalizationKeyAuditTests|FullyQualifiedName~DataOperationTests|FullyQualifiedName~HelpCommandVerificationTests"Fixes AzureCosmosDB/cosmosdb-shell-preview#27
Fixes AzureCosmosDB/cosmosdb-shell-preview#28