{"record":{"id":"f1fe5b4ead7b0c94","repo":"gohugoio/hugo","slug":"fileinfo-w","errorCode":null,"errorMessage":"fileInfo: %w","messagePattern":"fileInfo: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/fileInfo.go","lineNumber":31,"sourceCode":"\npackage hugolib\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/spf13/afero\"\n\n\t\"github.com/gohugoio/hugo/source\"\n)\n\ntype fileInfo struct {\n\t*source.File\n}\n\nfunc (fi *fileInfo) Open() (afero.File, error) {\n\tf, err := fi.FileInfo().Meta().Open()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"fileInfo: %w\", err)\n\t}\n\n\treturn f, err\n}\n\nfunc (fi *fileInfo) Lang() string {\n\treturn fi.File.Lang()\n}\n\nfunc (fi *fileInfo) String() string {\n\tif fi == nil || fi.File == nil {\n\t\treturn \"\"\n\t}\n\treturn fi.Path()\n}\n","sourceCodeStart":13,"sourceCodeEnd":47,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/fileInfo.go#L13-L47","documentation":"Wrapped by fileInfo.Open() when the underlying source file metadata's Open() call fails. The fileInfo struct wraps a source.File; calling Open() delegates to the file's FileInfo().Meta().Open() and re-wraps any error with the 'fileInfo:' prefix for tracing. It is a low-level I/O failure surfaced while Hugo reads a content/source file (e.g. during page reads or the source walk).","triggerScenarios":"Produced when (fi *fileInfo).Open() is invoked and fi.FileInfo().Meta().Open() returns a non-nil error — typically because the backing afero filesystem cannot read the file (deleted, permissions, broken symlink, missing mount target).","commonSituations":"A content file is removed or renamed mid-build (common during `hugo server` watch while the editor saves/deletes); a content directory mount points at a path the process cannot read; a symlink loop or broken symlink inside content; permission errors after a chmod/chown in CI.","solutions":["Check the wrapped error (%w) — it names the real OS-level cause (ENOENT, EACCES, etc.) and the path.","If running `hugo server`, re-save the file or confirm the file still exists on disk after editor operations.","Verify filesystem permissions/ownership on the content directory and that the mount target paths in config exist.","Remove or fix broken symlinks inside content/ and module mounts."],"exampleFix":"// before: mount points to a removed dir\n[[mounts]]\nsource = \"content/posts/drafts\"  // deleted on disk\n\n// after: remove the stale mount or restore the directory\n[[mounts]]\nsource = \"content/posts\"","handlingStrategy":"try-catch","validationCode":"// Before opening, stat the file via the same afero fs to fail early:\nif _, err := fi.FileInfo().Meta().Fs.Stat(path); err != nil {\n    return fmt.Errorf(\"pre-check stat failed: %w\", err)\n}","typeGuard":"// Hugo is Go; treat any non-nil error from Open() as the signal.\n// No type narrowing needed — callers should errors.Is/As the wrapped cause:\nif errors.Is(err, fs.ErrNotExist) { /* handle missing file */ }","tryCatchPattern":"f, err := fi.Open()\nif err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        // I/O-level cause; log path and skip or fail the page\n        h.Log.Errorf(\"open %s: %v\", perr.Path, perr)\n        return\n    }\n    return err\n}\ndefer f.Close()","preventionTips":["Avoid mutating content files during an active build/watch; pause editing or re-save cleanly.","Keep mounts pointing at stable, existing directories; validate mount sources at startup.","Run builds with consistent file ownership/permissions in CI."],"tags":["filesystem","io","content","source-files","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}