[bug-bash] print maps a missing item's HTTP 404 to exit 1 instead of documented not-found exit 5
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with PrintCommand.PrintItemAsync and its ReadItemStreamAsync NotFound branch, then trace how ShellExitCode maps command errors to exit codes. Check the documented exit-code contract and nearby tests for point reads. Done means a missing item still gets the friendly error and returns exit code 5.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C#
- Stars
- 4
- Forks
- 7
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/CosmosDBShell
-
bug bug-bash
Difficulty 3/5 1-2 days Newbie friendliness 75/100
Azure/CosmosDBShell#281 ·
Maintainers usually reply within 1 day
-
bug bug-bash
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Azure/CosmosDBShell#280 ·
Maintainers usually reply within 1 day
-
[bug-bash] edit and theme failures silently return exit 1 without a machine-readable stderr errorOpenbug bug-bash
Difficulty 3/5 1-2 days Newbie friendliness 62/100
Azure/CosmosDBShell#278 ·
Maintainers usually reply within 1 day
-
bug bug-bash
Difficulty 3/5 1-2 days Newbie friendliness 75/100
Azure/CosmosDBShell#277 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Azure/CosmosDBShell#274 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Azure/CosmosDBShell
Similar issues
-
needs-area-label
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days
-
bug github_actions
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
endercodezz/BYDLO#336 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
SubtitleEdit/subtitleedit#16638 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
sebastienros/jint#4449 ·
Maintainers usually reply within 1 day