{"record":{"id":"2039b9a8697f7501","repo":"gohugoio/hugo","slug":"failed-to-compile-redirect-glob-q-w","errorCode":null,"errorMessage":"failed to compile Redirect glob %q: %w","messagePattern":"failed to compile Redirect glob %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/commonConfig.go","lineNumber":270,"sourceCode":"\t}\n\tfor _, h := range s.Headers {\n\t\tg, err := glob.Compile(h.For)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compile Headers glob %q: %w\", h.For, err)\n\t\t}\n\t\ts.compiledHeaders = append(s.compiledHeaders, g)\n\t}\n\tfor _, r := range s.Redirects {\n\t\tif r.From == \"\" && r.FromRe == \"\" {\n\t\t\treturn fmt.Errorf(\"redirects must have either From or FromRe set\")\n\t\t}\n\t\trd := redirect{\n\t\t\theaders: make(map[string]glob.Glob),\n\t\t}\n\t\tif r.From != \"\" {\n\t\t\tg, err := glob.Compile(r.From)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile Redirect glob %q: %w\", r.From, err)\n\t\t\t}\n\t\t\trd.from = g\n\t\t}\n\t\tif r.FromRe != \"\" {\n\t\t\tre, err := regexp.Compile(r.FromRe)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile Redirect regexp %q: %w\", r.FromRe, err)\n\t\t\t}\n\t\t\trd.fromRe = re\n\t\t}\n\t\tfor k, v := range r.FromHeaders {\n\t\t\tg, err := glob.Compile(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile Redirect header glob %q: %w\", v, err)\n\t\t\t}\n\t\t\trd.headers[k] = g\n\t\t}\n\t\ts.compiledRedirects = append(s.compiledRedirects, rd)","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/commonConfig.go#L252-L288","documentation":"Emitted by Server.CompileConfig when a redirect's `from` glob fails to compile via gobwas/glob. Distinct from 277 (regexp) and 278 (header glob); this is specifically the redirect's primary glob matcher.","triggerScenarios":"A `[[server.redirects]]` with `from` containing invalid glob syntax such as an unclosed brace or bracket.","commonSituations":"Using regex metacharacters in a glob field; malformed brace expansion like `/old{a,b`.","solutions":["Validate `from` as a glob (not regexp).","Balance braces/brackets; simplify to `/path/*` to confirm."],"exampleFix":"# before\n[[server.redirects]]\nfrom = \"/old{a,b\"\nto = \"/new\"\n\n# after\n[[server.redirects]]\nfrom = \"/old{a,b}\"\nto = \"/new\"","handlingStrategy":"validation","validationCode":"python3 - <<'PY'\nimport tomllib\ncfg=tomllib.loads(open('hugo.toml').read())\nfor r in cfg.get('server',{}).get('redirects',[]):\n    f=r.get('from','')\n    if f:\n        assert f.count('{')==f.count('}') and f.count('[')==f.count(']'), f\"unbalanced glob {f!r}\"\nprint(\"redirect globs ok\")\nPY","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use glob syntax for redirect `from`.","Balance braces/brackets; simplify to `/path/*` to test."],"tags":["config","server","redirects","glob"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}