Skip to content

Report unclosed quotes in response files - #8448

Merged
Amaury Levé (Evangelink) merged 6 commits into
mainfrom
copilot/fix-unclosed-quotes-in-response-files
May 25, 2026
Merged

Amaury Levé (Evangelink) merged 6 commits into
mainfrom
copilot/fix-unclosed-quotes-in-response-files

Conversation

Copilot AI commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Malformed quoted tokens in response files were silently accepted, causing unterminated arguments to be dropped while TryReadResponseFile still reported success. This can turn a response-file typo into misleading or partial command-line parsing.

  • Response file parsing

    • Detects unbalanced quotes while splitting response-file lines.
    • Converts malformed response-file syntax into a failed TryReadResponseFile result.
    • Includes the response file path and line number in the reported error.
  • Tokenization behavior

    • SplitCommandLine now rejects unterminated quoted input instead of returning an empty or partial result.
--filter "FullyQualifiedName~My.Namespace

Now reports a response-file parse error instead of silently dropping the filter argument.

  • Coverage
    • Adds focused coverage for malformed quoted input in response files.
    • Updates the direct tokenizer test to expect a parse failure for unclosed quotes.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 21, 2026 08:14
Copilot AI changed the title [WIP] Fix unclosed quotes in response files handling Report unclosed quotes in response files May 21, 2026
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review May 21, 2026 09:25
Copilot AI review requested due to automatic review settings May 21, 2026 09:25

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.

Pull request overview

This pull request improves Microsoft.Testing.Platform command-line response file handling by treating malformed quoted tokens as parsing errors (rather than silently accepting and dropping unterminated arguments), and updates unit tests to cover the new behavior.

Changes:

  • Detect and fail response-file parsing when a line contains an unclosed quote, including reporting the response-file line number.
  • Update SplitCommandLine to reject unterminated quoted input by throwing FormatException.
  • Add/adjust unit tests to validate the new failure behavior for malformed quoted input.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ResponseFileHelperTests.cs Adds coverage for unclosed quotes in response files and updates tokenizer test expectations to require failure.
src/Platform/Microsoft.Testing.Platform/CommandLine/ResponseFileHelper.cs Adds line-aware tokenization for response-file lines and throws FormatException on unclosed quotes; TryReadResponseFile converts format errors into a failed result.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

- Catch UnauthorizedAccessException in TryReadResponseFile and report via the standard CommandLineParserFailedToReadResponseFile error path.
- Move unclosed-quote FormatException messages into PlatformResources for localization and drop trailing periods to avoid doubled punctuation when wrapped by CommandLineParserFailedToReadResponseFile.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was a copy from System.CommandLine. I would be skeptical to making changes here without validating System.CommandLine behavior first and even then, I would fix it in S.CL first before making a change here.

Per review feedback, drop the unrelated catch (UnauthorizedAccessException)
addition so this PR stays focused on reporting unclosed quotes in
response files.

Addresses review feedback on PR #8448.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 23, 2026 15:13

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's findings

  • Files reviewed: 16/16 changed files
  • Comments generated: 1

Amaury Levé (Evangelink) and others added 2 commits May 23, 2026 17:26
Replace the brittle "line 2" / "Unclosed quote" substring asserts with
a single check that the offending line number ("2") is present in the
error message. The message is rendered from a localized resource, so
asserting English fragments would break on non-en-US CI agents.

Addresses review feedback on PR #8448.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink
Amaury Levé (Evangelink) merged commit bbe148e into main May 25, 2026
35 of 37 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/fix-unclosed-quotes-in-response-files branch May 25, 2026 09:08
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.

[MTP Core Analysis] Unclosed quotes in response files are silently ignored

4 participants