error-pattern-safety

Solid

Apply safe error-pattern matching rules for agentic engines.

AI & Automation 4,819 stars 466 forks Updated today MIT

Install

View on GitHub

Quality Score: 90/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Error Pattern Safety Guidelines Use these regex safety rules in agentic engines to prevent JavaScript infinite loops. ## The Problem With the JavaScript global flag (`/pattern/g`), zero-width matches can cause infinite loops because: 1. JavaScript's `regex.exec()` with the `g` flag uses `lastIndex` to track position 2. When a pattern matches zero-width, `lastIndex` doesn't advance 3. The same position is matched repeatedly, causing an infinite loop ## Dangerous Pattern Examples **❌ NEVER USE THESE PATTERNS:** ```javascript // Pure .* - matches everything including empty string at end /.*/g // Single character with * - matches zero or more (including zero) /a*/g // Patterns that can match empty string /(x|y)*/g ``` ## Safe Pattern Examples **✅ ALWAYS USE PATTERNS LIKE THESE:** ```javascript // 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 ``` ## Pattern Safety Rules 1. **Always require at least one character match** - Use `.+` instead of `.*` when you need "something" - Ensure pattern has required prefix/suffix 2. **Never use bare `.*` as the entire pattern** - Always combine with required text: `error.*` - Never just `.*` or `.*?` 3. **Test patterns against empty string** ```javascript const regex = /your-pattern/g; if (regex.test("")) { throw new E...

Details

Author
github
Repository
github/gh-aw
Created
11 months ago
Last Updated
today
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category