-
Notifications
You must be signed in to change notification settings - Fork 38
Prevent ANSI escape sequences in compiled workflow YAML files #11068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
- 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 <[email protected]>
Remove unnecessary fmt.Sprintf in test Co-authored-by: mnkiefer <[email protected]>
|
@copilot add tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot revert this file
|
LEAVE THIS OPEN. Investigation underway. |
|
@copilot add tests |
1 similar comment
|
@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 <[email protected]>
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. |
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: