nektos/act · error
invalid Pattern '%s': %s
Error message
invalid Pattern '%s': %s
What it means
Returned by PatternToRegex (pkg/workflowpattern/workflow_pattern.go) when the branch/path filter pattern contains syntax errors. The translator walks the pattern (handling *, **, +, ?, [...], backslash escapes) collecting per-position errors in a map, then aggregates them as 'invalid Pattern ...: Position N Error: ...' before regex compilation.
Source
Thrown at pkg/workflowpattern/workflow_pattern.go:132
pos++
break
}
rpattern.WriteString(regexp.QuoteMeta(string([]byte{pattern[pos+1]})))
pos += 2
default:
rpattern.WriteString(regexp.QuoteMeta(string([]byte{pattern[pos]})))
pos++
}
}
if len(errors) > 0 {
var errorMessage strings.Builder
for position, err := range errors {
if errorMessage.Len() > 0 {
errorMessage.WriteString(", ")
}
errorMessage.WriteString(fmt.Sprintf("Position: %d Error: %s", position, err))
}
return "", fmt.Errorf("invalid Pattern '%s': %s", pattern, errorMessage.String())
}
rpattern.WriteString("$")
return rpattern.String(), nil
}
func CompilePatterns(patterns ...string) ([]*WorkflowPattern, error) {
ret := []*WorkflowPattern{}
for _, pattern := range patterns {
cp, err := CompilePattern(pattern)
if err != nil {
return nil, err
}
ret = append(ret, cp)
}
return ret, nil
}
// returns true if the workflow should be skipped paths/branchesView on GitHub (pinned to 4f41128141)
Solutions
- Read each 'Position: N' in the message to find the exact offending character
- Close unclosed brackets, avoid empty [] and out-of-order ranges, remove the trailing backslash
- Use only supported glob syntax: *, **, ?, +, [a-z]-style classes, and \ to escape a literal character
- Test patterns with CompilePattern in a scratch Go test before deploying
Example fix
# before: branches: [main, release-[a-z} # after: branches: [main, 'release-[a-z]']
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate branch/path filter patterns at config load time:
if _, err := workflowpattern.CompilePatterns("main", "release-[0-9]*"); err != nil {
log.Fatalf("bad filter pattern: %v", err)
} Try / catch
Return the error up to config loading; print the Position markers and reject the workflow file — never ignore.
Prevention
- Close every [ with a ] and never use empty []
- Use only a-z, A-Z, 0-9 inside ranges, in ascending order
- Escape literal special chars with a single backslash followed by the character (no trailing backslash)
- Prefer simple *, ** patterns over bracket classes when possible
When it happens
Trigger: Specific bad constructs: empty brackets '[]' (line 69), invalid character ranges in brackets like [z-a] or non A-z/0-9 chars (lines 81-97), missing closing ']' (line 106), or a trailing backslash with nothing to escape (line 113). Used for `on: push: branches:/paths:` filters.
Common situations: Writing glob patterns with shell-style ranges that contain invalid chars, forgetting to close a bracket, ending a pattern with a lone backslash, or copying regex syntax (e.g. \d, +) that the glob translator treats literally or rejects.
Related errors
- %s is not a valid mac address
- invalid value: %d. Valid memory swappiness range is 0-100
- invalid range format for --expose: %w
- invalid logging opts for driver %s
- invalid --security-opt: %q
AI-assisted analysis of nektos/act@4f41128141 (2026-08-15).
Data as JSON: /api/errors/6d47d9c0747b4dfa.
Report an issue: GitHub.