[bug-bash] print maps a missing item's HTTP 404 to exit 1 instead of documented not-found exit 5
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #288 來自 @mkrueger —— 已合併
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
研究方向
從 PrintCommand.PrintItemAsync 及其 ReadItemStreamAsync 的 NotFound 分支開始,接著追蹤 ShellExitCode 如何將命令錯誤對應至結束代碼。檢查文件中記載的結束代碼契約,以及附近針對單筆讀取的測試。完成標準是:項目不存在時,仍顯示友善的錯誤訊息並回傳結束代碼 5。
由索引模型根據 Issue 內容生成。
描述
Environment
Windows x64, CosmosDBShell 1.1.291-preview (db49321323).
Verified on a disposable container with partition key /pk, using an authorized
Azure CLI identity and Gateway connection mode.
Repro
The following creates a unique disposable shared-throughput database (400 RU/s)
and an empty container. Supply an authorized Azure NoSQL account using these
environment variables; no real endpoint or identity is included in this report:
# Set COSMOS_ENDPOINT, AZURE_SUBSCRIPTION_ID and COSMOS_RESOURCE_GROUP first.
foreach ($name in @('COSMOS_ENDPOINT', 'AZURE_SUBSCRIPTION_ID', 'COSMOS_RESOURCE_GROUP')) {
if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) {
throw "Set $name to an authorized test account value before continuing."
}
}
$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
$connection = @(
'--connect', $env:COSMOS_ENDPOINT,
'--connect-azure-cli', '--connect-mode', 'gateway',
'--connect-subscription', $env:AZURE_SUBSCRIPTION_ID,
'--connect-resource-group', $env:COSMOS_RESOURCE_GROUP,
'--output', 'json', '--quiet'
)
$db = 'BugBash_Print_' + [guid]::NewGuid().ToString('N')
& $shell @connection -c "mkdb $db --scale=m --ru=400"
if ($LASTEXITCODE -ne 0) { throw 'Fixture database creation failed; stop.' }
& $shell @connection --database $db -c 'mkcon Items /pk'
if ($LASTEXITCODE -ne 0) { throw 'Fixture container creation failed; stop.' }
# Exact failing command. The new container is empty, so this item cannot exist.
& $shell @connection --database $db --container Items -c 'print absent p1'
$readExit = $LASTEXITCODE
"Observed exit code: $readExit"
Actual: Observed exit code 1. Expected: 5.
Expected
A point read that returns HTTP 404 maps to not-found exit code 5, as documented
in the CLI's exit-code contract.
Actual
The command returns exit code 1, with a JSON stderr error saying the item was
not found and suggesting the partition key be verified.
Observed direct live reproduction:
print absent p1
stderr:
{"status":"error","error":"Item with id 'absent' not found using partition key 'p1'. Verify the partition key value is correct."}
Also reproduced for an item correctly absent after atomic batch rollback, and
after a successful explicit item deletion. This is an exit-code classification
bug, not a batch rollback or item deletion failure.
Cleanup
Delete only the database created by the commands above:
& $shell @connection -c "rmdb $db true"
Investigation lead
PrintCommand.PrintItemAsync uses ReadItemStreamAsync. Its explicit NotFound
branch throws a plain CommandException without preserving the HTTP status or
an SDK exception. ShellExitCode therefore cannot recognize the original 404
and falls back to general failure.
The fix should preserve the useful friendly error message while retaining the
original status classification. No fix has been implemented.
- 主要語言
- C#
- 星號
- 4
- 分支
- 7
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 33
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Azure/CosmosDBShell 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 35/100
Azure/CosmosDBShell#274 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
Azure/CosmosDBShell#265 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
Azure/CosmosDBShell#240 ·
維護者通常 1 天內回覆
-
automation P1
難度 5/5 一週以上 新手友好度 45/100
Azure/CosmosDBShell#178 · 1 則留言 ·
維護者通常 1 天內回覆
-
Lightweight headless CI distribution (no MCP, LSP, interactive UI)可能重新可做 關聯的 PR 已關閉且未合併。 未關閉automation P1
難度 5/5 一週以上 新手友好度 35/100
Azure/CosmosDBShell#175 · 1 則留言 ·
維護者通常 1 天內回覆
查看 Azure/CosmosDBShell 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
Facepunch/sbox-public#12305 ·
維護者通常 5 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
JiaFeiMiao-K-Cat/DiscImageStudio#205 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
flyingpie/windows-terminal-quake#419 ·
維護者通常 1 天內回覆
-
enhancement help wanted
難度 2/5 1-3 小時 新手友好度 82/100
-
a-corriger documentation
難度 1/5 1-3 小時 新手友好度 83/100
christian-raj/S-Aloha#272 ·