{"id":"8b5d77ae66664e8a","repo":"gofiber/fiber","slug":"failed-to-render-w","errorCode":null,"errorMessage":"failed to render: %w","messagePattern":"failed to render: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"res.go","lineNumber":769,"sourceCode":"\tvar rendered bool\n\tfor _, prefix := range slices.Backward(rootApp.mountFields.appListKeys) {\n\t\tapp := rootApp.mountFields.appList[prefix]\n\t\tif prefix == \"\" || strings.Contains(r.c.OriginalURL(), prefix) {\n\t\t\tif len(layouts) == 0 && app.config.ViewsLayout != \"\" {\n\t\t\t\tlayouts = []string{\n\t\t\t\t\tapp.config.ViewsLayout,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Render template from Views\n\t\t\tif app.config.Views != nil {\n\t\t\t\tif err := func() error {\n\t\t\t\t\tviewsLock := getViewsLock(app.config.Views)\n\t\t\t\t\tviewsLock.RLock()\n\t\t\t\t\tdefer viewsLock.RUnlock()\n\n\t\t\t\t\tif err := app.config.Views.Render(buf, name, bind, layouts...); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to render: %w\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nil\n\t\t\t\t}(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\trendered = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif !rendered {\n\t\t// Render raw template using 'name' as filepath if no engine is set\n\t\tvar tmpl *template.Template\n\t\tif _, err := readContent(buf, name); err != nil {\n\t\t\treturn err","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/res.go#L751-L787","documentation":"The configured template engine (app.Config.Views, e.g. html/pongo/jet from gofiber/template) returned an error rendering 'name' with bind and the given layouts. The wrapped error comes from the engine and typically means 'template not found', 'template syntax error', or a missing referenced layout.","triggerScenarios":"c.Render(\"user.tmpl\", data) where user.tmpl does not exist in the Views loader, has a syntax error, or references a layout file that is missing; or Views was not set on the app.","commonSituations":"Wrong template name/path; template file deleted or not embedded in the build; ViewsLayout configured but layout file absent; engine loaded with the wrong directory.","solutions":["Verify the template name matches a template the Views loader can resolve (check the loader root and extension).","Ensure app.Config.Views is set and the engine is loaded (e.g. html.New(\"./views\", \".html\")).","Check that any referenced layout exists and templates have no syntax errors."],"exampleFix":"// before\napp := fiber.New() // Views not configured\nc.Render(\"index\", data) // failed to render: template not found\n\n// after\nengine := html.New(\"./views\", \".html\")\napp := fiber.New(fiber.Config{Views: engine})\nc.Render(\"index\", data)","handlingStrategy":"validation","validationCode":"// at startup, assert the engine loaded the templates you expect\nif err := engine.Load(); err != nil {\n    log.Fatalf(\"views load failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := c.Render(name, bind, layouts...); err != nil {\n    log.Errorf(\"render %q failed: %v\", name, err)\n    return c.Status(fiber.StatusInternalServerError).SendString(\"render error\")\n}","preventionTips":["Set app.Config.Views and load it at startup.","Keep template names and extensions consistent with the loader.","Embed templates (go:embed) so missing files fail at build, not runtime."],"tags":["template","render","fiber"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}