{"record":{"id":"55929454b3213133","repo":"kataras/iris","slug":"walk-s-w","errorCode":null,"errorMessage":"walk: %s: %w","messagePattern":"walk: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"view/fs.go","lineNumber":27,"sourceCode":")\n\n// walk recursively in \"fileSystem\" descends \"root\" path, calling \"walkFn\".\nfunc walk(fileSystem fs.FS, root string, walkFn filepath.WalkFunc) error {\n\tif root != \"\" && root != \"/\" && root != \".\" {\n\t\tsub, err := fs.Sub(fileSystem, root)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfileSystem = sub\n\t}\n\n\tif root == \"\" {\n\t\troot = \".\"\n\t}\n\n\treturn fs.WalkDir(fileSystem, root, func(path string, d fs.DirEntry, err error) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"walk: %s: %w\", path, err)\n\t\t}\n\n\t\tinfo, err := d.Info()\n\t\tif err != nil {\n\t\t\tif err != filepath.SkipDir {\n\t\t\t\treturn fmt.Errorf(\"walk stat: %s: %w\", path, err)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}\n\n\t\tif info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\twalkFnErr := walkFn(path, info, err)\n\t\tif walkFnErr != nil {\n\t\t\treturn fmt.Errorf(\"walk: walkFn: %w\", walkFnErr)","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/view/fs.go#L9-L45","documentation":"The view helper walk traverses a filesystem (io/fs.FS) with fs.WalkDir; if the walk callback receives a non-nil error for a path (e.g. unreadable directory, invalid root), it wraps it as 'walk: <path>: <err>'. This gives the caller precise context about which path failed during template/asset discovery.","triggerScenarios":"Calling the walk-based loader (used when registering view engines with a directory or FS) with a root path that doesn't exist in the FS or that cannot be opened, so WalkDir's callback receives err != nil.","commonSituations":"Typo in the views directory name, embedding views with embed.FS but using the wrong embedded prefix, or a directory removed after build in deployment images.","solutions":["Verify the root directory exists and is spelled correctly relative to the FS root ('.' default).","When using embed.FS, embed the parent directory and strip the prefix (fs.Sub) so paths resolve.","Ensure the process has read permission on the directory tree.","Check the wrapped inner error for the OS-level cause (ENOENT, EACCES)."],"exampleFix":"// before\nview.New(HTML(\"./viwes\", \".html\")) // typo\n// after\nview.New(HTML(\"./views\", \".html\"))","handlingStrategy":"validation","validationCode":"root := \"./views\"\nif info, err := os.Stat(root); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"views root %q missing\", root)\n}","typeGuard":null,"tryCatchPattern":"if err := view.Register(engines...); err != nil {\n    var werr *fs.PathError\n    if errors.As(err, &werr) && strings.HasPrefix(err.Error(), \"walk:\") {\n        log.Fatalf(\"views tree unreadable at %s: %v\", werr.Path, werr.Err)\n    }\n    return err\n}","preventionTips":["Verify the views directory path at app startup, before registering engines.","For embed.FS, embed a parent dir and use fs.Sub to strip prefixes so paths resolve.","Ensure the deployment image actually contains the views directory."],"tags":["filesystem","view","walk"],"backgroundTag":"path-not-found","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}