{"id":"bfcb672d01695c9a","repo":"gohugoio/hugo","slug":"invalid-deployment-matchers-pattern-v","errorCode":null,"errorMessage":"invalid deployment.matchers.pattern: %v","messagePattern":"invalid deployment\\.matchers\\.pattern: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deploy/deployconfig/deployConfig.go","lineNumber":167,"sourceCode":"\t\tdcfg.Workers = 10\n\t}\n\n\tfor _, tgt := range dcfg.Targets {\n\t\tif *tgt == (Target{}) {\n\t\t\treturn dcfg, errors.New(\"empty deployment target\")\n\t\t}\n\t\tif err := tgt.ParseIncludeExclude(); err != nil {\n\t\t\treturn dcfg, err\n\t\t}\n\t}\n\tvar err error\n\tfor _, m := range dcfg.Matchers {\n\t\tif *m == (Matcher{}) {\n\t\t\treturn dcfg, errors.New(\"empty deployment matcher\")\n\t\t}\n\t\tm.Re, err = regexp.Compile(m.Pattern)\n\t\tif err != nil {\n\t\t\treturn dcfg, fmt.Errorf(\"invalid deployment.matchers.pattern: %v\", err)\n\t\t}\n\t}\n\tfor _, o := range dcfg.Order {\n\t\tre, err := regexp.Compile(o)\n\t\tif err != nil {\n\t\t\treturn dcfg, fmt.Errorf(\"invalid deployment.orderings.pattern: %v\", err)\n\t\t}\n\t\tdcfg.Ordering = append(dcfg.Ordering, re)\n\t}\n\n\treturn dcfg, nil\n}\n","sourceCodeStart":149,"sourceCodeEnd":180,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/deploy/deployconfig/deployConfig.go#L149-L180","documentation":"Raised at deployConfig.go:167 when `regexp.Compile(m.Pattern)` fails for a `deployment.matchers` entry. Matcher patterns are Go RE2 regular expressions matched against remote paths; a syntactically invalid regex makes the whole deployment config decode fail fast rather than silently skipping the matcher.","triggerScenarios":"`hugo deploy` with a `[[deployment.matchers]]` `pattern` that is not valid RE2 — unbalanced parentheses/brackets, dangling `*` or `+`, or RE2-unsupported constructs like backreferences (`\\1`) and lookaheads (`(?=...)`).","commonSituations":"Writing a glob (`*.js`) where a regex is expected; porting PCRE patterns with lookahead/backreferences that RE2 rejects; TOML single-vs-double-quote escaping mistakes turning `\\.` into an invalid sequence.","solutions":["Fix the regex: patterns must be valid Go RE2, e.g. use `^.+\\.(js|css)$` instead of glob syntax like `*.js`.","Remove PCRE-only constructs (lookahead/behind, backreferences) — RE2 does not support them; rewrite with alternation.","In TOML, prefer single-quoted literal strings (`pattern = '^.+\\.(js|css)$'`) to avoid double-escaping backslashes.","Test the pattern at https://go.dev/play or with `regexp.MustCompile` in a scratch Go file."],"exampleFix":"# before\n[[deployment.matchers]]\npattern = \"*.js\"\n\n# after\n[[deployment.matchers]]\npattern = '^.+\\.js$'","handlingStrategy":"validation","validationCode":"for i, m := range cfg.Deployment.Matchers {\n    if _, err := regexp.Compile(m.Pattern); err != nil {\n        return fmt.Errorf(\"deployment.matchers[%d] pattern %q: %w\", i, m.Pattern, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := deployConfig.Validate(); err != nil {\n    var syntaxErr *syntax.Error\n    if errors.As(err, &syntaxErr) {\n        log.Fatalf(\"bad matcher regexp: %v\", syntaxErr)\n    }\n    return err\n}","preventionTips":["Matcher patterns are Go RE2 regexps, not globs — test them with regexp.Compile or regex101 (Golang flavor) first","Escape literal dots and other metacharacters (e.g. `\\\\.html$` not `.html$`)","Run `hugo deploy --dryRun` in CI so a bad pattern fails before touching the target"],"tags":["hugo","deploy","regex","config-validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}