Skip to content

Preserve '?' in unquoted command arguments - #262

Merged
Mike Krüger (mkrueger) merged 1 commit into
mainfrom
dev/mkrueger/fix/260-index-path-question-mark
Oct 28, 2026
Merged

Mike Krüger (mkrueger) merged 1 commit into
mainfrom
dev/mkrueger/fix/260-index-path-question-mark

Conversation

@mkrueger

Copy link
Copy Markdown
Collaborator

Fixes #260.

Problem

index add /city/? failed with HTTP 400 ("The indexing path '/city/' could not be accepted"), although the same policy succeeded through index set and a direct SDK read-modify-write.

The root cause is in command-argument parsing, not the policy round trip: unquoted shell words stopped at the ? token, so /city/? was split into the arguments /city/ and ?. The incremental add therefore sent an invalid /city/ path to Cosmos DB. The full-policy index set worked because its paths are inside a quoted JSON string.

Fix

Treat ? as a shell-word continuation character in CommandShellWordParser, alongside /, *, :, etc. This applies to direct commands, exec, command expressions, and inline option values.

User-visible effects beyond indexing paths: unquoted words such as a?b, wildcard patterns like file?.csh, and URLs with query strings now stay single arguments instead of being split. A standalone ?, quoted strings, and statement separators are unchanged.

Tests

  • Parser: /city/? is preserved across direct commands, exec, command expressions, inline option values, and ; statement boundaries, with correct source ranges.
  • Execution: exec "echo" arguments match direct arguments for ?-containing paths and URLs.
  • Offline policy round trip: service-returned metadata (indexes, isFullIndex, composite/spatial/vector/full-text indexes) is preserved exactly when adding a path.
  • Emulator integration (IndexPolicyTests), using the selective policy from the issue with independent SDK readback:
    • the SDK read-modify-write control succeeds;
    • index add /city/? succeeds, and a repeated add is idempotent;
    • all other policy members are unchanged;
    • index remove /city/? restores the original policy.

Validation: both projects build; offline suite (Category!=Emulator) 4,894 passed / 5 skipped; emulator indexing tests pass. Verified against the local Windows emulator — not yet against the Linux vNext image from the issue. Readback confirms accepted configuration only, not emulator index-performance behavior.

Unquoted shell words stopped at '?', so 'index add /city/?' sent '/city/' to Cosmos DB and the service rejected the indexing policy with HTTP 400. Treat '?' as part of a shell word so scalar indexing paths and wildcard patterns reach commands unchanged.

Fixes #260

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change preserving ? in unquoted shell arguments.

No open issues 🎉

What changed in this PR

Fixes #260 by preserving ? within unquoted shell arguments, allowing scalar indexing paths such as /city/? to reach Cosmos DB unchanged.

Changes:

  • Updates shared argument parsing for direct commands, exec, command expressions, and inline option values.
  • Adds parser, execution, policy-preservation, and emulator readback regression coverage.
  • Documents unquoted indexing paths and distinguishes accepted policy metadata from emulator indexing-performance support.
File Description
docs/​commands.md Clarifies unquoted path support and readback limitations.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Parser/​CommandShellWordParser.cs Allows ? to continue an unquoted shell word.
CosmosDBShell.Tests/​Parser/​StatementParserStructureTests.cs Covers command forms, source ranges, and statement boundaries.
CosmosDBShell.Tests/​Parser/​CommandExecutionTests.cs Adds execution cases for paths and URLs containing ?.
CosmosDBShell.Tests/​Integration/​IndexPolicyTests.cs Adds SDK control and readback checks for add, repeated add, and remove.
CosmosDBShell.Tests/​CommandTests/​DataPlaneCosmosResourceOperationsTests.cs Checks policy metadata preservation through an incremental add.
CHANGELOG.md Records the unquoted-argument parsing fix.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main c666573 dev/mkrueger/fix/260... 99b9995 +/-
72% 72% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@mkrueger
Mike Krüger (mkrueger) merged commit 86efb3c into main Oct 28, 2026
13 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/fix/260-index-path-question-mark branch October 28, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index add returns HTTP 400 for a policy accepted by SDK and index set on the vNext emulator

3 participants