Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Fix MCP Gateway Configuration Validation for GitHub Actions Expressions

Problem

The MCP gateway configuration validation fails with "invalid character '$' in string escape code" because GitHub Actions expressions like ${{ github.workspace }} are not being properly substituted before JSON validation.

Root Cause

The prepareConfigForValidation() function in pkg/workflow/mcp_renderer.go substitutes shell variables (e.g., $MCP_GATEWAY_PORT, ${MCP_GATEWAY_DOMAIN}) but does NOT handle GitHub Actions expressions (e.g., ${{ github.workspace }}).

Solution Plan

  • Investigate current validation logic in prepareConfigForValidation()
  • Add regex-based substitution for GitHub Actions expressions
  • Handle all common patterns: ${{ github.* }}, ${{ env.* }}, etc.
  • Test the fix with smoke-copilot workflow
  • Run unit tests and validation
  • Run make agent-finish before committing
Original prompt

Review validation of generated mcp server payload and fix the JSON schema or generated code. You need to take into account uninterpolated expressions:

@pelikhan ➜ /workspaces/gh-aw (main) $ ./gh-aw compile smoke-copilot --validate
⚠ Using experimental feature: safe-inputs
⚠ Generated MCP gateway configuration is not valid JSON: invalid character '$' in string escape code
⚠ Invalid workflow YAML written to: .github/workflows/smoke-copilot.invalid.yml
✗ .github/workflows/smoke-copilot.md:1:1: error: workflow schema validation failed: GitHub Actions schema validation failed: jsonschema validation failed with 'https://json.schemastore.org/github-workflow.json#'
- at '/jobs/conclusion': 'oneOf' failed, none matched
  - at '/jobs/conclusion/steps/0/uses': got null, want string
  - at '/jobs/conclusion': validation failed
    - at '/jobs/conclusion': missing property 'uses'
    - at '/jobs/conclusion': additional properties 'outputs', 'steps', 'runs-on' not allowed
- at '/jobs/detection': 'oneOf' failed, none matched
  - at '/jobs/detection/steps/0/uses': got null, want string
  - at '/jobs/detection': validation failed
    - at '/jobs/detection': missing property 'uses'
    - at '/jobs/detection': additional properties 'runs-on', 'timeout-minutes', 'outputs', 'steps' not allowed
- at '/jobs/pre_activation': 'oneOf' failed, none matched
  - at '/jobs/pre_activation/steps/0/uses': got null, want string
  - at '/jobs/pre_activation': validation failed
    - at '/jobs/pre_activation': missing property 'uses'
    - at '/jobs/pre_activation': additional properties 'runs-on', 'outputs', 'steps' not allowed
- at '/jobs/safe_outputs': 'oneOf' failed, none matched
  - at '/jobs/safe_outputs/steps/0/uses': got null, want string
  - at '/jobs/safe_outputs': validation failed
    - at '/jobs/safe_outputs': missing property 'uses'
    - at '/jobs/safe_outputs': additional properties 'env', 'outputs', 'steps', 'runs-on', 'timeout-minutes' not allowed
- at '/jobs/update_cache_memory': 'oneOf' failed, none matched
  - at '/jobs/update_cache_memory/steps/0/uses': got null, want string
  - at '/jobs/update_cache_memory': validation failed
    - at '/jobs/update_cache_memory': missing property 'uses'
    - at '/jobs/update_cache_memory': additional properties 'runs-on', 'steps' not allowed
- at '/jobs/activation': 'oneOf' failed, none matched
  - at '/jobs/activation/steps/0/uses': got null, want string
  - at '/jobs/activation': validation failed
    - at '/jobs/activation': missing property 'uses'
    - at '/jobs/activation': additional properties 'outputs', 'steps', 'runs-on' not allowed
- at '/jobs/agent': 'oneOf' failed, none matched
  - at '/jobs/agent': validation failed
    - at '/jobs/agent/steps/0/uses': got null, want string
    - at '/jobs/agent/steps/2/uses': got null, want string
  - at '/jobs/agent': validation failed
    - at '/jobs/agent': missing property 'uses'
    - at '/jobs/agent': additional properties 'runs-on', 'env', 'outputs', 'steps' not allowed

⚠ Engine 'copilot' does not support the web-search tool. See https://githubnext.github.io/gh-aw/guides/web-search/ for alternatives.

💡 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.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan closed this Jan 26, 2026
Copilot AI requested a review from pelikhan January 26, 2026 20:08
Copilot stopped work on behalf of pelikhan due to an error January 26, 2026 20: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.

2 participants