Skip to content

[CI Failure Doctor] ANSI Escape Sequences in YAML Workflow Files - PR #11045 #11062

@github-actions

Description

@github-actions

Summary

CI failure in run #21219621737 caused by ANSI terminal escape sequences accidentally included in YAML workflow files. This issue was self-healing - the problematic commit was quickly superseded by subsequent commits that removed the escape codes.

Failure Details

Root Cause Analysis

The commit introduced ANSI escape sequences ([m - color reset codes) into the compiled workflow YAML file:

Affected lines in .github/workflows/cli-version-checker.lock.yml:

  • Line 810: 2. **REQUIRED**: Run 'make recompile' to update workflows (MUST be run after any constant changes)[m
  • Line 886: - **SAVE TO CACHE**: Store help outputs (main and all subcommands) and version check results in cache-memory[m

The [m characters are ANSI escape codes (specifically, \x1b[m or ESC[m) used for resetting terminal colors. These were likely:

  1. Copied from colored terminal output
  2. Preserved by a text editor with ANSI code support
  3. Or generated by a script that outputs colored text

These escape codes are invisible in many editors but break YAML parsing, causing the js job to fail during workflow validation.

Investigation Findings

What happened:

  1. PR Enforce mandatory recompile in cli-version-checker workflow #11045 was merged at 17:39:40 (commit 80395ca)
  2. CI workflow ran and failed at ~17:42:12 (js job failure)
  3. Repository continued with normal development
  4. By commit c4a0b67 (17:41:51), the ANSI codes were gone
  5. Current main branch is clean (no ANSI escape sequences found)

Why it self-healed:
The repository appears to have a rapid commit cycle with multiple PRs being merged. The problematic YAML file was likely regenerated (via make recompile) by a subsequent PR that produced clean YAML without the escape codes.

Failed Jobs and Errors

Job: js (61050540090)

  • Status: failure
  • Likely error: YAML syntax validation failed due to unexpected characters

Note: Full job logs were inaccessible (403 permission error), but the diff analysis clearly shows the ANSI escape code injection.

Recommended Actions

Immediate (Already Resolved ✅)

  • ✅ The issue self-resolved - current main branch has no ANSI escape sequences
  • ✅ No manual intervention needed

Prevention (Future Improvements)

  1. Add YAML validation to pre-commit hooks

    # Check for ANSI escape sequences in YAML files
    git diff --cached --name-only | grep '\.ya\?ml$' | xargs grep -P '\\x1b\\[[0-9;]*m' && exit 1
  2. Add CI validation step before JS job

    - name: Check for ANSI escape sequences
      run: |
        if find .github/workflows -name "*.yml" -o -name "*.yaml" | xargs grep -P '\\x1b\\[[0-9;]*m'; then
          echo "ERROR: ANSI escape sequences found in YAML files"
          exit 1
        fi
  3. Update compiler to strip ANSI codes

    • Modify the workflow compiler in pkg/workflow/ to automatically strip ANSI escape sequences
    • Add test cases that verify ANSI codes are removed during compilation
  4. Editor configuration guidance

    • Document in CONTRIBUTING.md that editors should not preserve ANSI escape codes
    • Recommend plaintext-only modes for editing YAML

Prevention Strategies

Root cause: Copy-paste operations from colored terminal output or ANSI-aware editors.

Prevention layers:

  1. Detection: Pre-commit hooks to catch ANSI codes before commit
  2. Validation: CI checks that fail fast on ANSI escape sequences
  3. Sanitization: Compiler automatically strips ANSI codes during workflow generation
  4. Education: Developer documentation about ANSI code hazards

AI Team Self-Improvement

Add to AGENTS.md or developer instructions:

### YAML File Editing - ANSI Escape Code Prevention

**CRITICAL**: When editing or generating YAML workflow files (`.github/workflows/*.yml`, `*.lock.yml`):

1. **NEVER copy-paste from colored terminal output** - Always use `--no-color` or `2>&1 | cat` to strip colors
2. **Validate YAML before committing** - Run `python3 -c "import yaml; yaml.safe_load(open('file.yml'))"` to check syntax
3. **Check for invisible characters** - Use `cat -A file.yml | grep '\[m'` to detect ANSI escape sequences
4. **Run make recompile** - Always recompile workflows after editing .md files to regenerate clean .lock.yml files

**Example of safe command usage**:
```bash
# ❌ BAD - May include ANSI color codes
npm view @github/copilot | tee output.txt

# ✅ GOOD - Strip colors before saving
npm view @github/copilot --no-color | tee output.txt
# OR
npm view @github/copilot 2>&1 | cat | tee output.txt

Detection command:

# Check for ANSI escape sequences in workflow files
find .github/workflows -name "*.yml" -o -name "*.yaml" | xargs grep -P '\\x1b\\[[0-9;]*m'

## Historical Context

This is the **first recorded instance** of ANSI escape sequences breaking CI in this repository. The error pattern has been documented in `/tmp/gh-aw/cache-memory/patterns/ansi-escape-yaml.json` for future reference.

**Similar past failures**: None found in issue search

**Pattern signature**: `[m` characters at end of YAML string values, representing ANSI color reset codes (`\x1b[m`)

**Investigation data**: Full investigation details stored at `/tmp/gh-aw/cache-memory/investigations/2026-01-21-21219621737.json`

## Additional Notes

- This was a **transient failure** with automatic recovery
- No production impact (caught by CI before affecting end users)
- Demonstrates the value of CI validation catching subtle errors
- Highlights need for better ANSI code detection in the toolchain




> AI generated by [CI Failure Doctor](https://github.com/githubnext/gh-aw/actions/runs/21219703333)
>
> 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/21219703333 -->

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions