Skip to content

Include full command in MTP command-line validation error messages #6201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 28, 2025

When running MTP applications with invalid command-line arguments, error messages previously only showed the problematic option without context about the complete command that was executed. This made debugging difficult in automation scenarios where users might not see the actual command being invoked.

Problem

The original error message was not helpful for debugging:

Option '--dotnet-test-pipe' from provider 'Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments

In automation scenarios like CI/CD pipelines, users often don't see the exact command being run, making it hard to understand what went wrong.

Solution

Added a new ToCommandLine() method to CommandLineParseResult that reconstructs the full command from parsed options. Updated validation error messages to include the complete command that was executed.

After

The error message now includes the full command for better debugging:

Option '--dotnet-test-pipe' from provider 'Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments. Command: /path/to/TestProject.dll --dotnet-test-pipe arg1 arg2

Changes Made

  • Added ToCommandLine() method: Reconstructs the command line from CommandLineParseResult including tool name, options, and arguments
  • Updated error message resources: Modified PlatformResources.resx to include command context in validation error messages
  • Updated validation logic: Modified CommandLineOptionsValidator to use the reconstructed command in error messages
  • Updated localization files: Updated all .xlf files with new source strings for proper localization support
  • Updated tests: Modified ArgumentArityTests to reflect new error message format

Implementation Details

The ToCommandLine() method properly handles:

  • Tool names and executable paths
  • Multiple options with arguments
  • Arguments containing spaces (properly quoted)
  • Edge cases like empty options or missing tool names

This is a minimal change that only affects error message formatting without modifying parsing logic or public APIs.

Fixes #6194.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…mmand

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] MTP command-line validation should include the whole command used for running Include full command in MTP command-line validation error messages Jul 28, 2025
@Copilot Copilot AI requested a review from Evangelink July 28, 2025 12:39
Copilot finished work on behalf of Evangelink July 28, 2025 12:39
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 command-line validation should include the whole command used for running
2 participants