{"record":{"id":"66e7e0753acad34d","repo":"gohugoio/hugo","slug":"failed-to-compile-ignorefiles-pattern-q-s","errorCode":null,"errorMessage":"failed to compile ignoreFiles pattern %q: %s","messagePattern":"failed to compile ignoreFiles pattern %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/allconfig.go","lineNumber":375,"sourceCode":"\t\tcase bool:\n\t\t\treturn v\n\t\tcase map[string]bool:\n\t\t\treturn v[section]\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t}\n\n\tignoreFile := func(s string) bool {\n\t\treturn false\n\t}\n\tif len(c.IgnoreFiles) > 0 {\n\t\tregexps := make([]*regexp.Regexp, len(c.IgnoreFiles))\n\t\tfor i, pattern := range c.IgnoreFiles {\n\t\t\tvar err error\n\t\t\tregexps[i], err = regexp.Compile(pattern)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile ignoreFiles pattern %q: %s\", pattern, err)\n\t\t\t}\n\t\t}\n\t\tignoreFile = func(s string) bool {\n\t\t\tfor _, r := range regexps {\n\t\t\t\tif r.MatchString(s) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t}\n\n\tvar clock time.Time\n\tif c.Internal.Clock != \"\" {\n\t\tvar err error\n\t\tclock, err = time.Parse(time.RFC3339, c.Internal.Clock)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse clock: %s\", err)","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/allconfig.go#L357-L393","documentation":"Returned by CompileConfig when compiling the `ignoreFiles` regex patterns fails. Each pattern is compiled with regexp.Compile; a syntax error in any pattern aborts config compilation and names the offending pattern plus the regexp error.","triggerScenarios":"Setting `ignoreFiles = [\"\\\\.foo(\", \"[a-\"]\"]` or any PCRE/Go-re2 syntax error: unbalanced parentheses, malformed character classes, unsupported look-ahead (re2 has none), or stray backslashes.","commonSituations":"Porting ignore patterns from JavaScript/PCRE regex dialects into Hugo (which uses Go's RE2 engine), unescaped backslashes in TOML strings, or trailing partial patterns from manual edits.","solutions":["Test each pattern with a Go regexp playground or `go run -` using regexp.Compile.","Use RE2-compatible syntax; remove look-ahead/look-behind and backreferences.","Double-escape backslashes in TOML (`\\\\.` not `\\.`) and verify in YAML/JSON accordingly.","Remove patterns one by one to isolate the bad one."],"exampleFix":"// before\nignoreFiles = [\"\\\\.draft(\"]\n// after\nignoreFiles = [\"\\\\.draft$\"]","handlingStrategy":"validation","validationCode":"func compileIgnoreFiles(patterns []string) error {\n  for _, p := range patterns { if _, err := regexp.Compile(p); err != nil { return fmt.Errorf(\"bad ignoreFiles pattern %q: %w\", p, err) } }\n  return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test each ignoreFiles pattern with regexp.Compile before committing.","Prefer RE2 syntax; avoid look-around and backreferences.","Mind TOML backslash escaping (use \"\\\\.\")."],"tags":["config","regex","ignorefiles","re2","allconfig"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}