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

オープン
#280 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp
領域
cli

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C#
スター
4
フォーク
7
平均マージ
2日 2時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/CosmosDBShell のほかの issue

Azure/CosmosDBShell の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。