Skip to content

Fix implicit pipeline input between script commands - #292

Merged
Mike Krüger (mkrueger) merged 5 commits into
mainfrom
dev/mkrueger/fix/281-explicit-pipeline-input
Nov 5, 2026
Merged

Mike Krüger (mkrueger) merged 5 commits into
mainfrom
dev/mkrueger/fix/281-explicit-pipeline-input

Conversation

@mkrueger

Copy link
Copy Markdown
Collaborator

Summary

Fixes #281.

  • Treat only explicit | stages as pipeline input, so independent statements no longer feed earlier results into rm or other input-consuming commands.
  • Preserve real pipelines through functions, scripts, and dynamic exec; consume pipeline provenance when function/script invocations finish, including empty and return-only bodies.
  • Isolate command-expression execution from its caller's pipeline input while still allowing arguments to read the caller's JSON paths.
  • Add 39 regression cases, including exact-ID rm --dry-run previews after cd and print, redirected script output, nested invocations, and explicit-pipeline controls.
  • Document independent-statement behavior. No changelog update, per the release-only workflow.

Validation

  • App and test builds: passed, zero warnings/errors.
  • Focused parser/script/command suite: 2,340 passed.
  • Five new nested-invocation regressions failed before the follow-up fix and passed afterward.
  • Complete offline test set, executed in two batches: 5,108 passed, 6 skipped.
  • git diff --check: passed.

The combined offline run encountered an existing parallel temporary-file race: the dir JSON contract test enumerated a script file while CommandStatementTests.ScriptExpression_PreservesEnclosingOutputRedirection deleted it. Running the JSON contract class separately passed all 21 cases; the remaining batch passed 5,087 tests with 6 skipped. No unrelated code was changed to suppress the race.

Cosmos DB behavior is verified with mocks; no live data was modified.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Non-piped function and script calls can still read and forward stale results from preceding statements because the reset only covers registered commands; entry-point clearing and regressions for empty and return-only bodies are needed.

1 open issue
What changed in this PR

This PR addresses #281 by distinguishing explicit pipeline input from earlier statement results, preventing independent commands such as rm --dry-run from using stale input.

Changes:

  • Track and consume pipeline provenance across commands, functions, and scripts.
  • Isolate command-expression execution while preserving caller context for argument evaluation.
  • Add 39 regression cases and document independent-statement behavior.
File Description
docs/​programming.md Clarifies pipeline behavior between separate statements.
docs/​navigation.md Documents independent commands with an exact-ID preview example.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Parser/​Statement/​PipeStatement.cs Marks explicit pipeline stages and clears provenance afterward.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Parser/​Statement/​DefStatement.cs Clears pipeline provenance when function execution finishes.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Parser/​Statement/​CommandStatement.cs Clears non-piped command results and separates script execution state.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Parser/​Expression/​CommandExpression.cs Isolates expression execution from caller pipeline input.
CosmosDBShell/​Azure.Data.Cosmos.Shell.Core/​CommandState.cs Adds pipeline-input tracking.
CosmosDBShell.Tests/​CommandTests/​PipelineInputTests.cs Covers sequential commands, explicit pipelines, nested invocations, and exact-ID previews.

Review effort: Balanced

@github-code-quality

github-code-quality Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main 3acd215 dev/mkrueger/fix/281... 07a3395 +/-
75% 75% 0%
View coverage of the 10 most impacted files.
File main 3acd215 dev/mkrueger/fix/281... 07a3395 +/-
D:\a\CosmosDBSh...ds\Parameter.cs 82% 38% -44%
D:\a\CosmosDBSh...placeCommand.cs 83% 57% -26%
D:\a\CosmosDBSh...OptionBinder.cs 100% 83% -17%
D:\a\CosmosDBSh...nnectCommand.cs 30% 22% -8%
D:\a\CosmosDBSh...s\UdfCommand.cs 51% 44% -7%
D:\a\CosmosDBSh...iggerCommand.cs 53% 48% -5%
D:\a\CosmosDBSh...SprocCommand.cs 58% 53% -5%
D:\a\CosmosDBSh...ThemeCommand.cs 71% 70% -1%
D:\a\CosmosDBSh...ds\RmCommand.cs 42% 67% +25%
D:\a\CosmosDBSh...ds\CdCommand.cs 45% 74% +29%

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


Updated November 05, 2026 13:37 UTC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Active issues break explicit JSON-path argument evaluation and allow empty pipeline stages to forward stale results, potentially passing unintended data to a following rm command.

3 open issues

Review effort: Balanced

…sults in #292

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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 remain for the change separating explicit pipeline input from independent command results.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

The isolated execution state discards input from explicit expression-level pipes, causing previously valid nested filters to throw “requires piped JSON input” instead of returning results.

1 open issue
2 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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 remain that require changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@mkrueger
Mike Krüger (mkrueger) merged commit 6867370 into main Nov 5, 2026
13 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/fix/281-explicit-pipeline-input branch November 5, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants