Prevent ANSI escape sequences in compiled workflow YAML files#11068
Merged
Prevent ANSI escape sequences in compiled workflow YAML files#11068
Conversation
- Add StripANSIEscapeCodes function to pkg/stringutil - Strip ANSI codes from workflow descriptions, sources, and comments - Add comprehensive tests for ANSI stripping - Add integration test for YAML generation with ANSI codes Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Add validate-yaml job in CI to detect ANSI escape sequences - Document ANSI escape code prevention in AGENTS.md - Update js job to depend on validate-yaml Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Remove unnecessary fmt.Sprintf in test Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CI failure caused by ANSI escape sequences in YAML
Prevent ANSI escape sequences in compiled workflow YAML files
Jan 21, 2026
Contributor
|
@copilot add tests |
pelikhan
approved these changes
Jan 21, 2026
Contributor
|
LEAVE THIS OPEN. Investigation underway. |
|
@copilot add tests |
1 similar comment
Contributor
|
@copilot add tests |
- Added 7 additional test cases for StripANSIEscapeCodes: * Consecutive ANSI codes * ANSI with large parameters * RGB 24-bit colors * ANSI in middle of words * Save/restore cursor * Cursor positioning * Long strings with multiple codes - Added 5 integration tests for YAML generation: * TestGenerateYAMLStripsANSIFromAllFields * TestGenerateYAMLStripsANSIFromImportedFiles * TestGenerateYAMLStripsANSIFromStopTimeAndManualApproval * TestGenerateYAMLStripsANSIMultilineDescription * Enhanced original test - Fixed ANSI stripping in compiler_activation_jobs.go: * Strip from GH_AW_STOP_TIME environment variable * Strip from environment field for manual approval All 30 ANSI-related tests pass successfully. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Added comprehensive test coverage in commit c6ec268: Unit tests (24 test cases in
Integration tests (6 test cases in
Also fixed ANSI stripping in All 30 ANSI-related tests pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ANSI terminal escape sequences (
\x1b[31m,\x1b[0m,\x1b[m) were breaking YAML parsing when accidentally introduced through copy-paste from colored terminal output or ANSI-aware text editors.Changes
Compiler sanitization (
pkg/workflow/compiler_yaml.go,pkg/workflow/compiler_activation_jobs.go,pkg/stringutil/stringutil.go)GH_AW_STOP_TIMEenvironment variable,environmentfield for manual approval\x1b\[[0-9;]*[a-zA-Z]matches all common ANSI sequences (colors, formatting, cursor control)Comprehensive test coverage (
pkg/stringutil/stringutil_test.go,pkg/workflow/compiler_yaml_test.go)Documentation (
AGENTS.md)--no-colorflags, avoid copy-paste from colored outputfind .github/workflows -name "*.yml" | xargs grep -P '\x1b\[[0-9;]*[a-zA-Z]'Example
Before:
"description": "Run \x1b[31mmake recompile\x1b[0m after changes\x1b[m"After:
"description": "Run make recompile after changes"Before:
GH_AW_STOP_TIME: 2026-12-31\x1b[31mT23:59:59Z\x1b[0mAfter:
GH_AW_STOP_TIME: 2026-12-31T23:59:59ZOriginal prompt
This section details on the original issue you should resolve
<issue_title>[CI Failure Doctor] ANSI Escape Sequences in YAML Workflow Files - PR #11045</issue_title>
<issue_description>## 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
js(JavaScript linting/validation)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:2. **REQUIRED**: Run 'make recompile' to update workflows (MUST be run after any constant changes)[m- **SAVE TO CACHE**: Store help outputs (main and all subcommands) and version check results in cache-memory[mThe
[mcharacters are ANSI escape codes (specifically,\x1b[mor ESC[m) used for resetting terminal colors. These were likely:These escape codes are invisible in many editors but break YAML parsing, causing the
jsjob to fail during workflow validation.Investigation Findings
What happened:
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)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 ✅)
Prevention (Future Improvements)
Add YAML validation to pre-commit hooks
Add CI validation step before JS job
Update compiler to strip ANSI codes
pkg/workflow/to automatically strip ANSI escape sequencesEditor configuration guidance
Prevention Strategies
Root cause: Copy-paste operations from colored terminal output or ANSI-aware editors.
Prevention layers:
AI Team Self-Improvement
Add to AGENTS.md or developer instructions: