Skip to content

Fix four scripting parser and value-conversion bugs - #233

Open
Mike Krüger (mkrueger) wants to merge 1 commit into
mainfrom
dev/mkrueger/fix-scripting-edge-cases
Open

Mike Krüger (mkrueger) wants to merge 1 commit into
mainfrom
dev/mkrueger/fix-scripting-edge-cases

Conversation

@mkrueger

Copy link
Copy Markdown
Collaborator

Summary

Fix four scripting bugs that could execute malformed loop headers, select the wrong array element, fail decimal arithmetic on JSON string values, or reject valid dynamic command arguments.

Changes

  • Require the case-insensitive in keyword in for headers and while after do bodies. Invalid headers produce parser diagnostics before any statements in the input execute.
  • Reject filter array indexes that exceed Int32.MaxValue, including optional access, instead of silently substituting index zero. Representable indexes outside an array still return null.
  • Make JSON-to-decimal conversion return the same culture-invariant double representation as other shell values. Numeric JSON strings work in decimal arithmetic and comparisons; string concatenation with + remains unchanged.
  • Share command argument parsing between ordinary commands and exec, supporting options with space-separated, =, and : values, negative arguments, URLs, and file patterns while preserving typed expressions.
  • Add regression coverage for parser diagnostics, prevention of earlier execution, script scope restoration, filter errors, value origins, culture invariance, and dynamic command binding.
  • Update the changelog, README, scripting documentation, and filter specification.

Release scope

This is a follow-up for a future release and should not be included in the current release.

…exec

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.

Copilot review overview

🟡 Changes recommended

The value-conversion regression coverage does not follow the repository’s required value-origin matrix.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes four scripting issues involving loop validation, filter indexes, JSON numeric conversion, and dynamic exec arguments.

Changes:

  • Validates loop keywords and filter index ranges.
  • Aligns JSON decimal conversion with shell doubles.
  • Reuses command argument parsing for exec and adds regression coverage and documentation.
File Description
README.md Summarizes corrected scripting behavior.
docs/​programming.md Documents conversion, loops, and exec arguments.
docs/​filter-v1-spec.md Defines valid filter index bounds.
StatementParser.cs Validates keywords and shares argument parsing.
ShellJson.cs Returns invariant doubles for decimal conversion.
ExpressionParser.cs Rejects overflowing filter indexes.
ScriptExecutionScopeTests.cs Tests invalid scripts and scope restoration.
StatementParserEdgeTests.cs Tests keywords and exec parsing.
StatementExecutionTests.cs Tests loop preflight and numeric strings.
ShellObjectConversionTests.cs Updates JSON conversion expectations.
FilterPathExpressionTests.cs Tests index boundaries and overflow.
CultureInvariantConversionTests.cs Tests culture-independent JSON conversion.
CommandExecutionTests.cs Tests dynamic command argument execution.
FilterCommandTests.cs Tests filter overflow handling.
CHANGELOG.md Records the four fixes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

[InlineData("<=", "false")]
[InlineData(">", "true")]
[InlineData(">=", "true")]
public async Task JsonNumericStrings_MatchTextAcrossValueOrigins(string operation, string expected)
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit aed1c2b in the dev/mkrueger/fix-scr... branch remains at 66%, unchanged from commit dc14571 in the main branch.

Show a line coverage summary of the most impacted files.
File main dc14571 dev/mkrueger/fix-scr... aed1c2b +/-
D:\a\CosmosDBSh...tementParser.cs 77% 78% +1%
D:\a\CosmosDBSh...essionParser.cs 84% 85% +1%
D:\a\CosmosDBSh...llWordParser.cs 97% 99% +2%
D:\a\CosmosDBSh...xecStatement.cs 77% 79% +2%
D:\a\CosmosDBSh...onExpression.cs 69% 73% +4%
D:\a\CosmosDBSh...OptionBinder.cs 57% 74% +17%

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.

2 participants