Skip to content

Add devproxy config validate subcommand #1541

@waldekmastykarz

Description

@waldekmastykarz

Parent: #1534

Problem

There's no way for an agent to validate a Dev Proxy configuration file without actually starting the proxy. Starting the proxy modifies system state (system proxy settings, certificate installation, etc.) and is a long-running process. An agent that wants to verify its config changes are correct before starting the proxy has no safe option.

Rationale

Agents iteratively build and refine configuration files. A validate-then-fix loop is a core agent workflow pattern: generate config → validate → parse errors → fix → retry. Without a validation command, the agent must start the full proxy to discover config errors, which is slow, has side effects, and blocks the terminal.

Proposed solution

Add devproxy config validate [--config-file path] subcommand:

  1. Parse the config file
  2. Validate JSON against the schema
  3. Check that referenced plugins exist and can load
  4. Validate URL patterns are syntactically correct
  5. Check that referenced mock files / external files exist
  6. Return structured output (especially with --output json)

Human output:

✓ Configuration is valid
  Config file: ./devproxyrc.json
  Plugins: 3 loaded
  URLs to watch: 2 patterns

Warnings:
  - plugins[2].configSection.mocksFile: File 'mocks.json' not found

JSON output (--output json):

{
  "valid": true,
  "configFile": "./devproxyrc.json",
  "plugins": ["MockResponsePlugin", "RateLimitingPlugin", "RetryAfterPlugin"],
  "urlsToWatch": ["https://api.example.com/*", "https://graph.microsoft.com/*"],
  "errors": [],
  "warnings": [
    {
      "path": "plugins[2].configSection.mocksFile",
      "message": "File 'mocks.json' not found"
    }
  ]
}

Error output:

{
  "valid": false,
  "errors": [
    {
      "path": "plugins[1].name",
      "message": "Plugin 'NonExistentPlugin' not found"
    }
  ],
  "warnings": []
}

Exit code 0 for valid, 1 for invalid.

Affected code

  • DevProxy/Commands/ConfigCommand.cs — add validate subcommand
  • May need to factor out config loading/validation logic from Program.cs and plugin initialization

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions