Skip to content

[CI Failure Doctor] JS Test Suite Failure - 44 Tests Failing After PR #11053 (handle_agent_failure changes) #11081

@github-actions

Description

@github-actions

🏥 CI Failure Investigation - Run #21223010566

Summary

The CI workflow failed with 44 JavaScript test failures across 4 test files in the js job after merging PR #11053. The failures indicate that changes to handle_agent_failure.cjs and its tests were not properly synchronized with the safe outputs schema validation system.

Failure Details

Root Cause Analysis

🔴 PRIMARY ISSUE: Safe Output Schema Validation Failures (36 tests)

File: collect_ndjson_output.test.cjs
Error Pattern: expected [] to have a length of X but got +0

The commit changed handle_agent_failure.cjs and handle_agent_failure.test.cjs but did NOT update the safe outputs schema definitions. This caused widespread test failures in the validation system.

Failing test categories:

  1. Required field validation (8 tests)
    • add-labels, create-pull-request, create-discussion, create-pull-request-review-comment, update_release, assign_milestone, assign_to_agent
  2. JSON repair functionality (5 tests)
    • Array syntax issues, bracket type mismatches
  3. Code scanning alert validation (7 tests)
    • Valid entries, missing fields, invalid types, severity levels
  4. Sanitization (1 test)
    • Multi-field type handling
  5. Min validation (5 tests)
    • Min requirement enforcement across types
  6. Noop validation (1 test)
    • Multiple noop messages
  7. Link sub-issue temp ID validation (6 tests)
    • Temporary ID format, parent/sub issue validation

🟡 SECONDARY ISSUE: MCP Server Test Timeouts (2 tests)

File: safe_outputs_mcp_server_defaults.test.cjs
Error: Test timed out in 10000ms + AssertionError: expected undefined to deeply equal [...]

Tests:

  • should have optional branch parameter for create_pull_request
  • should have optional branch parameter for push_to_pull_request_branch

Root Cause: Tests expect schema properties to exist but receive undefined, suggesting schema structure mismatch.

🟢 TERTIARY ISSUE: Test Assertion Changes (2 tests)

File: close_older_issues.test.cjs
Error: Unexpected message format changes

Tests:

  • should limit to MAX_CLOSE_COUNT issues - Expected single warning message, received 3 formatted messages
  • should return empty array if no older issues found - Expected single info message, received 24 debug messages

Root Cause: Code now outputs more verbose logging that wasn't reflected in test assertions.

🔵 QUATERNARY ISSUE: Go Handler Failures (4 tests)

File: mcp_handler_go.test.cjs
Error: Various Go script execution failures

Failed Test Summary

  • Test Files: 4 failed | 140 passed (144 total)
  • Tests: 44 failed | 2876 passed | 17 skipped (2937 total)
  • Duration: 80.51s

Changes in PR #11053

Modified files:

  1. actions/setup/js/handle_agent_failure.cjs (+2, -4)
    • Changed parent issue title from "[agentics] Agentic Workflow Issues" to "[agentic-workflows] Failed runs"
    • Removed duplicate title from issue body
  2. actions/setup/js/handle_agent_failure.test.cjs (+3, -3)
    • Updated test assertions to match new title

The problem: These changes updated the templates but didn't synchronize with:

  • Safe output schema definitions in pkg/workflow/js/safe_outputs_tools.json
  • Validation logic expectations in test files
  • MCP server schema parameters

Investigation Findings

Why Did This Pass PR Review?

The PR likely didn't run the full test suite before merging, or tests passed locally but failed in CI due to:

  1. Missing npm test pre-commit check
  2. Schema files cached differently in CI vs local
  3. Environment-specific test behavior

Similar Past Issues

Found similar issue #9965 (closed) from Jan 14, 2026:

  • 46 test failures (similar count to current 44)
  • Same test files affected
  • Different root cause (filesystem permissions)
  • Pattern: JS tests frequently fail in CI after merges

Recommended Actions

🔴 IMMEDIATE FIX (Required to unblock main)

  1. Revert or fix PR Update parent issue template for agentic-workflow failures #11053 changes

    Option A: Quick revert

    git revert 23faa9c7916c23365605ddb707896d88616b2e61

    Option B: Fix schema sync (recommended)

    cd actions/setup/js
    npm ci
    # Update safe_outputs_tools.json schema definitions
    # Update validation expectations in tests
    npm test  # MUST pass before committing
  2. Update safe outputs schema

    Review and update pkg/workflow/js/safe_outputs_tools.json to match:

    • New parent issue title format
    • Updated field requirements
    • MCP server parameter definitions
  3. Fix test assertions

    Update test expectations in:

    • collect_ndjson_output.test.cjs - Fix validation logic expectations
    • safe_outputs_mcp_server_defaults.test.cjs - Add proper schema parameters
    • close_older_issues.test.cjs - Update message format expectations

🟡 MEDIUM PRIORITY - Prevent Recurrence

  1. Enforce pre-commit testing

    Add to .github/workflows/pre-commit.yml:

    - name: Run JavaScript tests
      run: |
        cd actions/setup/js
        npm ci
        npm test
  2. Add schema validation check

    Create a test that verifies schema files are in sync:

    test('safe outputs schema matches validation expectations', () => {
      const schema = require('../safe_outputs_tools.json');
      const validator = require('../collect_ndjson_output.cjs');
      // Verify all schema types have corresponding validators
    });
  3. Document schema sync process

    Add to CONTRIBUTING.md:

    ## Modifying Safe Outputs
    
    When changing handle_agent_failure.cjs or related files:
    1. Update pkg/workflow/js/safe_outputs_tools.json
    2. Update validation tests in collect_ndjson_output.test.cjs
    3. Run `npm test` before committing
    4. Verify schema parameters match MCP server definitions

Prevention Strategies

Pre-Commit Checklist for Safe Output Changes

# 1. Run JavaScript tests
cd actions/setup/js
npm ci && npm test

# 2. Check schema synchronization
grep -r "parent.*issue.*title" pkg/workflow/js/safe_outputs_tools.json
grep -r "parent.*issue.*title" actions/setup/js/*.test.cjs

# 3. Verify no failures
echo "All tests passed? Commit!"

Test Writing Rules

  1. Always update schema files when changing safe output templates
  2. Run full test suite before committing (npm test, not just unit tests)
  3. Verify CI passes before merging PRs
  4. Never skip test updates when modifying templates
  5. Never assume local tests === CI tests

AI Team Self-Improvement

Add to AI agent instructions in AGENTS.md:

## Safe Outputs Schema Synchronization

**CRITICAL: When modifying safe output templates or handlers:**

1. **Update all related files:**
   - Source: `actions/setup/js/handle_*.cjs`
   - Schema: `pkg/workflow/js/safe_outputs_tools.json`
   - Tests: `actions/setup/js/*.test.cjs`

2. **Schema sync checklist:**
   ```bash
   # After modifying any handle_*.cjs file:
   cd actions/setup/js
   npm test  # MUST pass
   
   # If tests fail, update schema files:
   # 1. pkg/workflow/js/safe_outputs_tools.json
   # 2. Test expectations in *.test.cjs files
  1. Common pitfalls:

    • ❌ Changing issue titles without updating schema
    • ❌ Modifying message formats without updating test assertions
    • ❌ Adding new fields without schema definitions
    • ✅ Always grep for related strings across all files
    • ✅ Run tests before AND after schema updates
  2. Pattern to follow:

    # Find all related definitions
    grep -r "your-new-text" actions/setup/js/
    grep -r "your-new-text" pkg/workflow/js/
    
    # Update all matches to maintain consistency

## Historical Context

**Pattern detected**: This is the 2nd major JS test failure in main branch within 2 weeks:
- **Issue #9965** (Jan 14): 46 tests failed (filesystem permissions)
- **Current** (Jan 21): 44 tests failed (schema sync)

**Root cause pattern**: Insufficient pre-commit validation for JavaScript changes.

**Recommendation**: Make `make test-js` mandatory in CI before merge approval.

---

## Investigation Metadata

- **Pattern**: `JS_TEST_SCHEMA_SYNC_FAILURE` (1st occurrence of this specific pattern)
- **Related Issues**: #9965 (similar JS test failure pattern)
- **Investigation Record**: `/tmp/gh-aw/cache-memory/investigations/2026-01-21-21223010566.json`
- **Created**: 2026-01-21T19:41:33Z

> 🤖 AI generated by [CI Failure Doctor](https://github.com/githubnext/gh-aw/actions/runs/21223192070)




> AI generated by [CI Failure Doctor](https://github.com/githubnext/gh-aw/actions/runs/21223192070)
>
> To add this workflow in your repository, run `gh aw add githubnext/agentics/workflows/ci-doctor.md@ea350161ad5dcc9624cf510f134c6a9e39a6f94d`. See [usage guide](https://githubnext.github.io/gh-aw/guides/packaging-imports/).

<!-- gh-aw-agentic-workflow: CI Failure Doctor, engine: copilot, run: https://github.com/githubnext/gh-aw/actions/runs/21223192070 -->

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions