Skip to content

Fix command usage exit codes across built-in commands - #289

Merged
Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/fix/280-command-usage-exit-codes
Nov 5, 2026
Merged

Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/fix/280-command-usage-exit-codes

Conversation

@mkrueger

Copy link
Copy Markdown
Collaborator

Summary

Return the documented usage exit code 2 for rejected command arguments and input validation, while preserving operational and service failure classifications.

  • Add an explicit usage-error marker without changing exception types, messages, or original causes.
  • Audit validation across built-in commands and shared option/positional binding, including expressions and dynamic execution.
  • Add metadata-driven binding tests for every built-in command, command-specific validation cases, and process regressions for all three issue examples.
  • Document the exit-code distinction and contributor guidance. Keep the release-only changelog policy change separate.

Validation

  • App and test builds passed without warnings.
  • Offline regression suite: 5,421 passed, 6 skipped.
  • Follow-up review validation: 706 focused tests passed.
  • git diff --check passed.

Fixes #280

Fixes #280

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@github-code-quality

github-code-quality Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main f6b1dd6 dev/mkrueger/fix/280... 2be01c3 +/-
74% 74% 0%
View coverage of the 10 most impacted files.
File main f6b1dd6 dev/mkrueger/fix/280... 2be01c3 +/-
D:\a\CosmosDBSh...osmosCommand.cs 80% 80% 0%
D:\a\CosmosDBSh...mportCommand.cs 96% 97% +1%
D:\a\CosmosDBSh...\FtabCommand.cs 83% 84% +1%
D:\a\CosmosDBSh...iggerCommand.cs 48% 53% +5%
D:\a\CosmosDBSh...SprocCommand.cs 53% 58% +5%
D:\a\CosmosDBSh...s\UdfCommand.cs 44% 51% +7%
D:\a\CosmosDBSh...nnectCommand.cs 22% 30% +8%
D:\a\CosmosDBSh...OptionBinder.cs 83% 100% +17%
D:\a\CosmosDBSh...placeCommand.cs 57% 83% +26%
D:\a\CosmosDBSh...ds\Parameter.cs 38% 82% +44%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 05, 2026 12:12 UTC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the changes distinguishing usage errors from operational failures.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the changes standardizing usage-error exit codes.

No open issues 🎉

Review effort: Balanced

@mkrueger
Mike Krüger (mkrueger) merged commit 4ab437a into main Nov 5, 2026
13 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/fix/280-command-usage-exit-codes branch November 5, 2026 13:28
@mkrueger
Mike Krüger (mkrueger) requested a balanced review from Copilot November 5, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the changes to standardize usage-error exit codes.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants