{"record":{"id":"40bb2b0d083e27c2","repo":"kataras/iris","slug":"walk-walkfn-w","errorCode":null,"errorMessage":"walk: walkFn: %w","messagePattern":"walk: walkFn: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"view/fs.go","lineNumber":45,"sourceCode":"\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)\n\t\t}\n\n\t\treturn nil\n\t})\n\n}\n\nfunc asset(fileSystem fs.FS, name string) ([]byte, error) {\n\tdata, err := fs.ReadFile(fileSystem, name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"asset: read file: %w\", err)\n\t}\n\n\treturn data, nil\n}\n\nfunc getFS(fsOrDir any) fs.FS {\n\treturn context.ResolveFS(fsOrDir)","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/view/fs.go#L27-L63","documentation":"After gathering path info, the walker invokes the user-supplied walkFn for each file; any error the callback returns is wrapped as 'walk: walkFn: <err>'. This distinguishes errors originating in the consumer's per-file logic from filesystem traversal errors.","triggerScenarios":"The internal walkFn used when loading view templates returns an error for a file — e.g. reading the file failed, or a per-template parse/validation step inside walkFn errored — and that error propagates through the wrapper.","commonSituations":"A template file readable at list time but unreadable at read time, a zero-byte/corrupt template file, or a template path that conflicts with a registered engine's expected naming.","solutions":["Read the wrapped inner error to identify the failing file and cause.","Fix or remove the offending template file in the views tree.","Ensure template files have proper read permissions and valid content.","Retry the load if the failure was caused by concurrent file replacement."],"exampleFix":"// before\ntemplates/empty.html (0 bytes) -> walkFn error\n// after\ntemplates/empty.html populated with valid template content","handlingStrategy":"try-catch","validationCode":"return fs.WalkDir(fsys, root, func(p string, d fs.DirEntry, err error) error {\n    if err != nil { return err }\n    info, _ := d.Info()\n    if !info.IsDir() {\n        f, err := fsys.Open(p)\n        if err != nil { return fmt.Errorf(\"preflight %s: %w\", p, err) }\n        f.Close()\n    }\n    return nil\n})","typeGuard":null,"tryCatchPattern":"if err := view.Register(engine); err != nil {\n    if strings.Contains(err.Error(), \"walk: walkFn:\") {\n        log.Fatalf(\"template processing failed: %v\", err)\n    }\n    return err\n}","preventionTips":["Preflight-read every file in the views tree before registering the engine.","Replace empty or corrupt template files with valid content.","Keep walkFn logic minimal — do parsing/validation in tests, not during the walk."],"tags":["filesystem","view","walk"],"backgroundTag":"walk-callback-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}