{"id":"d0ff64db6fcbb1bf","repo":"gohugoio/hugo","slug":"failed-to-load-codeowners-w","errorCode":null,"errorMessage":"failed to load CODEOWNERS: %w","messagePattern":"failed to load CODEOWNERS: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__new.go","lineNumber":95,"sourceCode":"\t\t},\n\t}\n\n\tif ps.IsHome() && ps.PathInfo().IsLeafBundle() {\n\t\tmsg := \"Using %s in your content's root directory is usually incorrect for your home page. \"\n\t\tmsg += \"You should use %s instead. If you don't rename this file, your home page will be \"\n\t\tmsg += \"treated as a leaf bundle, meaning it won't be able to have any child pages or sections.\"\n\t\tps.s.Log.Warnidf(constants.WarnHomePageIsLeafBundle, msg, ps.PathInfo().PathNoLeadingSlash(), strings.ReplaceAll(ps.PathInfo().PathNoLeadingSlash(), \"index\", \"_index\"))\n\t}\n\n\tif m.f != nil {\n\t\tgi, err := s.h.gitInfoForPage(ps)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load Git data: %w\", err)\n\t\t}\n\t\tps.gitInfo = gi\n\t\towners, err := s.h.codeownersForPage(ps)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load CODEOWNERS: %w\", err)\n\t\t}\n\t\tps.codeowners = owners\n\t}\n\n\tps.pageMenus = &pageMenus{p: ps}\n\tps.PageMenusProvider = ps.pageMenus\n\tps.GetPageProvider = pageSiteAdapter{s: s, p: ps}\n\tps.GitInfoProvider = ps\n\tps.TranslationsProvider = ps\n\tps.ResourceDataProvider = newDataFunc(ps)\n\tps.RawContentProvider = ps\n\tps.ChildCareProvider = ps\n\tps.TreeProvider = pageTree{p: ps}\n\tps.Eqer = ps\n\tps.TranslationKeyProvider = ps\n\tps.ShortcodeInfoProvider = ps\n\tps.AlternativeOutputFormatsProvider = ps\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page__new.go#L77-L113","documentation":"When a CODEOWNERS file is configured/present, Hugo maps each content file to its owners via `codeownersForPage` during page construction so templates can use `.CodeOwners`. If parsing the CODEOWNERS file or matching the page's path fails, page creation stops with this wrapped error.","triggerScenarios":"A build where a `CODEOWNERS` file exists (repo root, `.github/`, or `docs/`) and the codeowners parser fails on it — malformed pattern lines, unreadable file, or an error resolving the page's filename against the ruleset in `newPageFromMeta` (hugolib/page__new.go:93-96).","commonSituations":"Hand-edited CODEOWNERS with syntax GitHub tolerates but the Go codeowners parser rejects; encoding issues (BOM, CRLF oddities); CODEOWNERS copied from another tool with unsupported pattern syntax; file permission problems in containers.","solutions":["Read the wrapped error to find the offending CODEOWNERS line and fix its pattern syntax (standard gitignore-style patterns plus owner handles).","Validate the file with a CODEOWNERS linter or GitHub's own validation view.","If codeowners data isn't wanted in the build, remove/rename the CODEOWNERS file from the build context."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Verify CODEOWNERS parses before enabling codeowners support:\ntest -f CODEOWNERS || test -f .github/CODEOWNERS\n# Check each non-comment line is '<pattern> <owner>...' with no stray tokens","typeGuard":null,"tryCatchPattern":"if err := build(); err != nil {\n    if strings.Contains(err.Error(), \"CODEOWNERS\") {\n        log.Println(\"fix CODEOWNERS syntax or remove the file / disable the feature\")\n    }\n    return err\n}","preventionTips":["Lint CODEOWNERS in CI (GitHub validates it; use a codeowners linter locally)","Keep CODEOWNERS in a standard location (repo root, .github/, or docs/)","Only enable Hugo's codeowners page variable when the file exists and is valid","Avoid unsupported glob syntax in patterns"],"tags":["hugo","codeowners","parsing","build"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}