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

Aberta
#280 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@mkrueger já está trabalhando nisso.

Desde 4/11/2026.

  • #289 de @mkrueger — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
csharp
Domínio
cli

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
C#
Estrelas
4
Forks
7
Merge médio
1d 23h
PRs com merge (30d)
23

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Azure/CosmosDBShell

Todas as issues de Azure/CosmosDBShell

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.