Skip to content

Fix TypeScript type error: allow boolean in renderTemplate context#10439

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-js-tests-mcp-gateway
Jan 17, 2026
Merged

Fix TypeScript type error: allow boolean in renderTemplate context#10439
pelikhan merged 2 commits intomainfrom
copilot/fix-js-tests-mcp-gateway

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

The CI failure in PR #10421 was a TypeScript compilation error, not related to MCP Gateway format changes. The renderTemplate() function in messages_core.cjs only accepted string | number | undefined but received boolean values from handle_agent_failure.cjs.

Changes

  • Updated JSDoc type annotation in actions/setup/js/messages_core.cjs:
    // Before
    @param {Record<string, string|number|undefined>} context
    
    // After
    @param {Record<string, string|number|boolean|undefined>} context

Context

The error manifested at lines 292 and 338 in handle_agent_failure.cjs where secret_verification_failed: String(...) was passed to renderTemplate(). TypeScript flagged the boolean type before runtime string conversion.

const templateContext = {
  secret_verification_failed: String(secretVerificationResult === "failed"),  // boolean → string
  // ...other fields
};
const commentBody = renderTemplate(commentTemplate, templateContext);  // Type error here
Original prompt

This section details on the original issue you should resolve

<issue_title>[CI Failure Doctor] JS tests failed after PR #10421 merged - MCP Gateway format change broke tests</issue_title>
<issue_description># 🏥 CI Failure Investigation - Run githubnext/gh-aw#21089437610

⚠️ Critical Issue: PR Merged with Failing Tests

PR #10421 was merged to main despite the JS test job failing. This indicates a CI configuration issue where required checks are not properly blocking merges.

Summary

The CI workflow run for commit bb65d5921db32c7f27be4c37e47e8ed54b7359b4 (PR #10421) failed due to JavaScript test failures in the js job. The PR introduced changes to MCP Gateway schema validation, changing from Docker command format to the new container-based format specified in the MCP Gateway Specification v1.0.0.

Failure Details

Root Cause Analysis

Changes Made in PR #10421

The PR changed MCP Gateway config format from legacy Docker commands to the new MCP Gateway container-based format:

Before:

{
  "type": "stdio",
  "command": "docker",
  "args": ["run", "--rm", "-i", "mcp/ast-grep:latest"]
}

After:

{
  "type": "stdio",
  "container": "mcp/ast-grep:latest"
}

Files Modified

  1. pkg/workflow/mcp-config.go:

    • Removed transformation of container field to docker run commands
    • Now combines container + version into single image string
    • Updated property rendering to include container, entrypoint, entrypointArgs, mounts
  2. pkg/workflow/mcp_container_args_test.go:

    • Updated Go tests to expect MCP Gateway format
    • Tests now check result.Container instead of result.Command == "docker"
  3. Lock files regenerated (5 workflows):

    • .github/workflows/brave.lock.yml
    • .github/workflows/go-pattern-detector.lock.yml
    • .github/workflows/mcp-inspector.lock.yml
    • .github/workflows/notion-issue-summary.lock.yml
    • .github/workflows/scout.lock.yml

Failure Hypothesis

The JavaScript test job (actions/setup/js && npm test) failed, suggesting:

  1. Schema Validation Tests: JS tests may validate MCP config schema and expect the old Docker command format
  2. Runtime Validation: The compiled workflow lock files use the new format, but JS runtime validation may not support it yet
  3. Test Fixtures: Test fixtures or mocks may hardcode the old Docker command structure

Investigation Findings

What We Know

Go tests passed - The mcp_container_args_test.go was updated correctly
Workflow compilation succeeded - Lock files were regenerated successfully
JS tests failed - The js job failed at "Run tests" step
⚠️ Merged despite failure - PR was merged even though required tests failed

What Needs Investigation

  1. Which specific JS test(s) failed?
  2. Are JS tests checking MCP config format?
  3. Does the JS codebase have schema validation that needs updating?
  4. Why did the CI allow the merge despite the failed js job?

Recommended Actions

Immediate (Priority 1)

Short-term (Priority 2)

  • Fix JS tests: Update tests to work with new MCP Gateway format
  • Update schema validation: Ensure JS runtime validation supports new format
  • Verify lock files: Confirm regenerated lock files work correctly
  • Add regression tests: Ensure both formats are tested going forward

Long-term (Priority 3)

  • Fix CI configuration: Make js job a required check that blocks merges
  • Add pre-merge validation: Ensure all tests pass before allowing merge
  • Improve test coverage: Add integration tests for MCP config format changes
  • Document format migration: Add migration guide for MCP config format changes

Prevention Strategies

CI Configuration

  1. Required Checks: Ensure the js job is marked as required in branch protection rules
  2. Merge Blocking: Configure GitHub to block merges when required checks fail
  3. Status Checks: Add branch protection rule requiring js job to pass

Testing Strategy

  1. **Format Valid...

💡 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>
Copilot AI changed the title [WIP] Fix CI failure due to JS tests for MCP Gateway Fix TypeScript type error: allow boolean in renderTemplate context Jan 17, 2026
Copilot AI requested a review from pelikhan January 17, 2026 10:19
@pelikhan pelikhan marked this pull request as ready for review January 17, 2026 10:19
@pelikhan pelikhan merged commit fcabd3a into main Jan 17, 2026
@pelikhan pelikhan deleted the copilot/fix-js-tests-mcp-gateway branch January 17, 2026 10:19
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.

[CI Failure Doctor] JS tests failed after PR #10421 merged - MCP Gateway format change broke tests

2 participants