[bug-bash] Invalid command arguments return general-failure exit 1 instead of documented usage exit 2

Ouverte
#280 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@mkrueger y travaille déjà.

Depuis le 4/11/2026.

  • #289 par @mkrueger — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
csharp
Domaine
cli

Piste de recherche

Start by reading docs/ci.md and docs/navigation.md to confirm the exit-code contract, then trace how command argument validation errors are mapped to exit codes; the issue points to ArgumentException, JsonException, CommandNotFoundException, and plain CommandException paths. Reproduce the three commands in PowerShell without a database connection. Done when missing or invalid arguments return 2 while runtime failures retain their documented classification.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug bug-bash

Environment

Windows x64, CosmosDBShell 1.1.291-preview (db49321323).
No database connection is required.

Repro (PowerShell)

$package = "$env:USERPROFILE\.dotnet\tools\.store\cosmosdbshell\1.1.291-preview"
$shell = Join-Path $package 'cosmosdbshell.win-x64\1.1.291-preview\tools\net10.0\win-x64\CosmosDBShell.exe'
& $shell --version
$work = Join-Path ([IO.Path]::GetTempPath()) ("cosmos-usage-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $work | Out-Null
Set-Location $work
& $shell --output json -c 'echo [1] | filter'
"Exit code: $LASTEXITCODE"

Actual stderr:

{"status":"error","error":"Missing required parameter: ExpressionText"}

Actual exit code: 1.

Another example:

'[{"id":"a","pk":"a"}]' | Set-Content .\sample.json
& $shell --output json -c 'import sample.json --dry-run --concurrency 0'
"Exit code: $LASTEXITCODE"

Actual stderr:

{"status":"error","error":"Concurrency must be a positive integer."}

Actual exit code: 1.

Third exact command:

& $shell --output json -c 'echo [{"id":"a"}] | ftab --format invalid'
"Exit code: $LASTEXITCODE"

Actual stderr:

{"status":"error","error":"The -format option must be one of: default, markdown, html."}

Actual exit code: 1.

Expected

The documented exit-code contract in docs/ci.md
and docs/navigation.md assigns
code 2 to usage errors, invalid/bad arguments, and unknown options. Code 1 is
for failures that do not fit a more specific category. A missing required
parameter and an invalid concurrency argument should therefore classify as 2.

Working control

An unknown command or unknown app-level option correctly returns exit code 2.

Impact

CI wrappers cannot consistently distinguish incorrect invocation from a runtime
failure using the published exit-code contract.

Investigation lead

The current source maps ArgumentException, JsonException, and
CommandNotFoundException to usage errors. Several argument-validation paths
instead create a plain CommandException without a classified inner exception,
which falls through to general failure. This is a candidate root cause,
not a verified fix.

Reproduced against the installed release.

Langage dominant
C#
Étoiles
4
Forks
7
Merge moyen
1 j 23 h
PR mergées (30 j)
23

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Azure/CosmosDBShell

Toutes les issues de Azure/CosmosDBShell

Issues similaires

Plus d'issues C#

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.