{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/deploy/deployconfig/deployConfig.go#L149-L180","documentation":"DecodeConfig (deploy/deployconfig/deployConfig.go:165) compiles each [[deployment.matchers]] Pattern as a Go regexp (m.Re). This wraps regexp.Compile failure. Matchers attach Cache-Control/Content-Type/etc. metadata to uploaded files whose paths match.","triggerScenarios":"A [[deployment.matchers]] entry whose `pattern` is invalid regex, e.g. an unbalanced parenthesis, dangling quantifier, or glob-style '*' used where regex '.*' is required.","commonSituations":"Writing a glob pattern ('*.css') in a matchers.pattern, which must be a regex; copy-pasting a glob from elsewhere; unclosed character class.","solutions":["Treat matchers.pattern as a regex, not a glob: use '.*' for 'any' and anchor with '^'/'$' as needed.","Validate the pattern with regexp.Compile before adding it.","Escape literal dots/metacharacters ('\\.').","Balance all parentheses and character classes."],"exampleFix":"# before\n[[deployment.matchers]]\npattern = \"*.css\"          # glob syntax, invalid regex\ncacheControl = \"public\"\n\n# after\n[[deployment.matchers]]\npattern = \".*\\.css$\"\ncacheControl = \"public\"","handlingStrategy":"validation","validationCode":"import \"regexp\"\n\nfunc ValidateMatcherPattern(pattern string) error {\n    if _, err := regexp.Compile(pattern); err != nil {\n        return fmt.Errorf(\"matchers.pattern %q: %w\", pattern, err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := deployconfig.DecodeConfig(cfg); err != nil {\n    return err\n}","preventionTips":["matchers.pattern is a regex: use '.*' not '*'.","Escape literal dots/metacharacters.","Lint matchers patterns in CI."],"tags":["deploy","config","regex"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}