npx skills add ...
npx skills add github/gh-aw --skill error-pattern-safety
Apply safe error-pattern matching rules for agentic engines.
npx skills add github/gh-aw --skill error-pattern-safety
Use these regex safety rules in agentic engines to prevent JavaScript infinite loops.
With the JavaScript global flag (/pattern/g), zero-width matches can cause infinite loops because:
regex.exec() with the g flag uses lastIndex to track positionlastIndex doesn't advance❌ NEVER USE THESE PATTERNS:
✅ ALWAYS USE PATTERNS LIKE THESE:
Always require at least one character match
.+ instead of .* when you need "something"Never use bare .* as the entire pattern
error.*.* or .*?Test patterns against empty string
Use specific anchors when possible
^error.*.*error$\berror\bAll error patterns must pass the same safety checks used by the repo’s unit suite:
Run the relevant package tests with make test-unit.
Use the relevant *.test.cjs suite under actions/setup/js/ or pkg/workflow/js/ for the area you changed, or run the repo’s JavaScript checks via make test-js.
The repo’s validation helpers include built-in protections for dangerous regex patterns:
When adding new error patterns to engines:
Write the pattern with required content
Test against empty string
make test-unitTestAllEnginePatternsSafeTest with actual log samples
Document the pattern
Patterns are converted from Go to JavaScript:
The (?i) prefix is removed because JavaScript uses the i flag instead.
If you find a pattern that matches empty string:
Before (unsafe):
After (safe):
Before committing pattern changes:
make test-unitmake test-js or the targeted Vitest suitemake test-unit and make test-js// Required prefix before .*
/error.*/gi
/error.*permission.*denied/gi
// Specific structure with required content
/\[(\d{4}-\d{2}-\d{2})\]\s+(ERROR):\s+(.+)/g
// Required characters throughout
/access denied.*user.*not authorized/gi