Repository navigation
Report actual outcome of database/container creation - #263
Merged
Mike Krüger (mkrueger) merged 5 commits intoOct 29, 2026
Merged
Conversation
mkdb, mkcon, create database, and create container always reported created: true, even when an existing resource was reused. Carry an explicit creation outcome through the resource-operations abstraction: the data plane uses the SDK response status (201 created, 200 existing), and ARM reports created: null with outcome createdOrUpdated because its create-or-update API cannot distinguish the two. Human-readable messages match the structured result. Fixes #261
Mike Krüger (mkrueger)
requested review from
a team
and
a balanced review from Copilot
October 28, 2026 09:30
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the resource-creation outcome changes.
No open issues 🎉
What changed in this PR
Fixes #261 by carrying creation outcomes from the resource backends through the shell’s database and container commands, allowing automation to distinguish new resources from reused ones.
Changes:
- Reports data-plane creation from the SDK response status and ARM create-or-update as
created: nullwithoutcome: "createdOrUpdated". - Aligns structured results, localized messages, and documentation, including the ARM breaking change.
- Adds offline outcome tests and emulator coverage for replay, resource preservation, and partition-key mismatch errors.
| File | Description |
|---|---|
l10n/CosmosDBShell.json |
Adds generated creation-outcome messages. |
docs/mcp.md |
Explains creation outcomes for MCP consumers. |
docs/commands.md |
Documents backend-specific result semantics. |
CosmosDBShell/lang/en.ftl |
Adds existing and created-or-updated messages. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ResourceCreationResult.cs |
Defines the shared creation-result model. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ICosmosResourceOperations.cs |
Changes creation methods to return outcomes. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/DataPlaneCosmosResourceOperations.cs |
Derives creation status from SDK responses. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/CosmosResourceFacade.cs |
Propagates creation results to commands. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ArmCosmosResourceOperations.cs |
Returns an explicit unknown creation status. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeDbCommand.cs |
Reports database outcomes in results and messages. |
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeContainerCommand.cs |
Reports container outcomes in results and messages. |
CosmosDBShell.Tests/Integration/ResourceCreationTests.cs |
Tests replay outcomes and resource preservation. |
CosmosDBShell.Tests/CommandTests/ServerlessCreationThroughputTests.cs |
Updates assertions for the new result type. |
CosmosDBShell.Tests/CommandTests/ResourceCreationResultTests.cs |
Tests command output and ARM outcome semantics. |
CHANGELOG.md |
Records the reporting fix and ARM breaking change. |
Review effort: Balanced
Address CodeQL constant-condition findings on PR #263. The null arm is reachable (ARM create-or-update), so keep all three outcomes and centralize selection in ResourceCreationResult.Select.
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Replace the nullable Created flag with ResourceCreationOutcome (Created, Existing, CreatedOrUpdated) so the unknown ARM outcome is explicit rather than encoded as null. The structured result keeps its created/outcome fields; outcome is derived from the enum name in camelCase.
Vsevolod Kukol (sevoku)
approved these changes
Oct 28, 2026
Mike Krüger (mkrueger)
deleted the
dev/mkrueger/fix/261-creation-outcome
branch
October 29, 2026 11:16
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.
Fixes #261.
Problem
mkdb,mkcon,create database, andcreate containeralways returnedcreated: true, even when an existing resource was reused. Automation could not distinguish a new resource from an adopted one, so replays overcounted creations and audit trails described mutations that never happened.The data-plane backend already received the distinguishing status from
CreateDatabaseIfNotExistsAsync/CreateContainerIfNotExistsAsync(201 Created vs. 200 OK), but the resource-operations abstraction returned only the resource ID, and the commands hard-codedcreated = true.Fix
Carry an explicit
ResourceCreationResult(ID plus nullableCreated) throughICosmosResourceOperations, the facade, and both backends.createdoutcometruecreatedfalseexistingnullcreatedOrUpdatedBreaking change
On Entra ID (ARM) connections,
createdchanges fromtruetonull. Scripts that treatcreatedas a boolean should checkoutcomeinstead. This is listed under Breaking changes in the changelog.Tests
ResourceCreationResultTests): all four command forms × created/existing/ARM × user/JSON output. Checks that structured and human-readable results agree, and that the ARM path never reports a boolean or performs a preflight existence lookup, for both 200 and 202 responses.ResourceCreationTests):true; a replay reportsfalse.false.Validation: both projects build with 0 warnings; offline suite 4,914 passed / 5 skipped; emulator management and creation tests 14/14 passed. Also manually verified the CLI messages and JSON against the local emulator. ARM behavior is covered by mocks, not a live Azure account.
Localization: four new
en.ftlkeys with the regeneratedl10n/CosmosDBShell.json. Docs: management result semantics indocs/commands.mdand an MCP note indocs/mcp.md.