Repository navigation
Fix command usage exit codes across built-in commands - #289
Merged
Mike Krüger (mkrueger) merged 3 commits intoNov 5, 2026
Merged
Conversation
Fixes #280 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
requested review from
a team
and
a balanced review from Copilot
November 4, 2026 16:30
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Array replacement loses the missing-ID validation’s usage-error classification, returning exit code 1 instead of the single-object path’s exit code 2.
1 open issue
What changed in this PR
This PR addresses #280 by classifying rejected command arguments and input as usage errors (2), while keeping operational and service failures distinct.
Changes:
- Adds an explicit usage-error marker and applies it across built-in commands and shared argument binding.
- Adds binding, validation, exception-wrapper, and process-level regression tests.
- Documents the exit-code distinction and contributor guidance.
| File | Description |
|---|---|
| docs/navigation.md | Clarifies usage versus operational exit codes. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Parser/Statement/CommandStatement.cs | Marks missing and excess arguments as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Parser/Expression/FilterPathExpression.cs | Classifies invalid filter-path input. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Parser/Expression/FilterCallExpression.cs | Classifies invalid filter calls and input types. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Parser/CommandOptionBinder.cs | Marks option conversion failures as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellExitCode.cs | Recognizes usage markers and unknown options. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Core/PendingBulkState.cs | Classifies bulk capacity violations. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Core/CommandException.cs | Adds the usage-error marker and factory. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/WatchCommand.cs | Classifies invalid watch intervals. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/UdfCommand.cs | Marks function argument validation failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/TtlCommand.cs | Classifies invalid TTL arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/TriggerCommand.cs | Marks trigger argument validation failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThroughputCommand.cs | Classifies invalid throughput arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThemeCommand.cs | Marks selected theme validation failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/SprocCommand.cs | Classifies stored-procedure argument errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/RmCommand.cs | Marks removal argument validation failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ReplaceCommand.cs | Marks invalid replacement input. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/QueryCommand.cs | Classifies empty queries as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/PrintCommand.cs | Classifies missing IDs and invalid partition-key arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/PatchOperationFactory.cs | Marks invalid patch operations and values. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/PatchCommand.cs | Classifies invalid patch arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/Parameter.cs | Wraps positional conversion failures as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeItemCommand.cs | Classifies missing item input. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/MakeContainerCommand.cs | Marks invalid container configuration input. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/InfoCommand.cs | Classifies invalid scope and format options. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/IndexCommand.cs | Marks indexing-policy argument errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ImportCommand.cs | Classifies invalid import arguments and input data. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/HelpCommand.cs | Marks unknown help targets as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/FtabCommand.cs | Classifies invalid table input and options. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/FilterCommand.cs | Marks invalid filter expressions and input. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ExportCommand.cs | Classifies missing export filenames. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/EditCommand.cs | Classifies missing editor paths. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DoctorCommand.cs | Marks diagnostic argument validation failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DirCommand.cs | Classifies invalid directory filters. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DeleteCommand.cs | Marks unsupported deletion target types. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/CreateCommand.cs | Classifies invalid creation arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ConnectCommand.cs | Marks invalid connection modes. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ConflictCommand.cs | Classifies invalid conflict-policy arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/CdCommand.cs | Marks conflicting navigation arguments and excessive path depth. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/CanICommand.cs | Classifies unsupported permission-check actions. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkOperationNormalizer.cs | Marks rejected bulk operations as usage errors. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkCommand.cs | Separates bulk validation errors from operational failures. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BucketCommand.cs | Classifies invalid throughput-bucket arguments. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BatchOperationParser.cs | Marks invalid batch input and operations. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BatchExecutor.cs | Classifies invalid batch operation counts. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BatchCommand.cs | Marks batch argument and input errors. |
| CosmosDBShell.Tests/Runtime/ShellExitCodeTests.cs | Tests usage markers, wrappers, and preserved failure categories. |
| CosmosDBShell.Tests/Integration/ShellProcessTests.cs | Adds process exit-code regressions and an operational-failure control. |
| CosmosDBShell.Tests/CommandTests/CommandUsageErrorTests.cs | Adds metadata-driven binding and command validation coverage. |
| CosmosDBShell.Tests/CommandTests/BulkCommandTests.cs | Verifies capacity violations return usage errors. |
| CONTRIBUTING.md | Documents error classification and testing guidance. |
Review effort: Balanced
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Vsevolod Kukol (sevoku)
approved these changes
Nov 5, 2026
Mike Krüger (mkrueger)
deleted the
dev/mkrueger/fix/280-command-usage-exit-codes
branch
November 5, 2026 13:28
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
Return the documented usage exit code
2for rejected command arguments and input validation, while preserving operational and service failure classifications.Validation
git diff --checkpassed.Fixes #280