{"record":{"id":"6d47d9c0747b4dfa","repo":"nektos/act","slug":"invalid-pattern-s-s","errorCode":null,"errorMessage":"invalid Pattern '%s': %s","messagePattern":"invalid Pattern '(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/workflowpattern/workflow_pattern.go","lineNumber":132,"sourceCode":"\t\t\t\tpos++\n\t\t\t\tbreak\n\t\t\t}\n\t\t\trpattern.WriteString(regexp.QuoteMeta(string([]byte{pattern[pos+1]})))\n\t\t\tpos += 2\n\t\tdefault:\n\t\t\trpattern.WriteString(regexp.QuoteMeta(string([]byte{pattern[pos]})))\n\t\t\tpos++\n\t\t}\n\t}\n\tif len(errors) > 0 {\n\t\tvar errorMessage strings.Builder\n\t\tfor position, err := range errors {\n\t\t\tif errorMessage.Len() > 0 {\n\t\t\t\terrorMessage.WriteString(\", \")\n\t\t\t}\n\t\t\terrorMessage.WriteString(fmt.Sprintf(\"Position: %d Error: %s\", position, err))\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"invalid Pattern '%s': %s\", pattern, errorMessage.String())\n\t}\n\trpattern.WriteString(\"$\")\n\treturn rpattern.String(), nil\n}\n\nfunc CompilePatterns(patterns ...string) ([]*WorkflowPattern, error) {\n\tret := []*WorkflowPattern{}\n\tfor _, pattern := range patterns {\n\t\tcp, err := CompilePattern(pattern)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, cp)\n\t}\n\treturn ret, nil\n}\n\n// returns true if the workflow should be skipped paths/branches","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/workflowpattern/workflow_pattern.go#L114-L150","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before:\nbranches: [main, release-[a-z}\n# after:\nbranches: [main, 'release-[a-z]']","handlingStrategy":"validation","validationCode":"// Pre-validate branch/path filter patterns at config load time:\nif _, err := workflowpattern.CompilePatterns(\"main\", \"release-[0-9]*\"); err != nil {\n    log.Fatalf(\"bad filter pattern: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"Return the error up to config loading; print the Position markers and reject the workflow file — never ignore.","preventionTips":["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"],"tags":["go","act","glob-pattern","workflow-filters","validation"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}