{"record":{"id":"fa62f5b4c94c9d87","repo":"hasura/graphql-engine","slug":"cannot-fetch-template-w","errorCode":null,"errorMessage":"cannot fetch template: %w","messagePattern":"cannot fetch template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/pkg/console/consoleserver.go","lineNumber":155,"sourceCode":") (*gin.Engine, error) {\n\tvar op errors.Op = \"console.BuildConsoleRouter\"\n\t// An Engine instance with the Logger and Recovery middleware already attached.\n\tgin.SetMode(gin.ReleaseMode)\n\n\tr := gin.New()\n\n\tif !templateProvider.DoTemplateExist(\n\t\ttemplateProvider.BasePath() + templateVersion + templateProvider.TemplateFilename(),\n\t) {\n\t\ttemplateVersion = \"latest\"\n\t}\n\t// Template console.gohtml\n\ttemplateRender, err := templateProvider.LoadTemplates(\n\t\ttemplateProvider.BasePath()+templateVersion+\"/\",\n\t\ttemplateProvider.TemplateFilename(),\n\t)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cannot fetch template: %w\", err))\n\t}\n\n\tr.HTMLRender = templateRender\n\n\tif staticDir != \"\" {\n\t\tr.Use(static.Serve(\"/static\", static.LocalFile(staticDir, false)))\n\t\topts[\"cliStaticDir\"] = staticDir\n\t}\n\n\tr.GET(\"/*action\", func(c *gin.Context) {\n\t\tc.HTML(http.StatusOK, templateProvider.TemplateFilename(), &opts)\n\t})\n\n\treturn r, nil\n}\n","sourceCodeStart":137,"sourceCodeEnd":171,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/pkg/console/consoleserver.go#L137-L171","documentation":"BuildConsoleRouter loads the console HTML template (console.gohtml) from the template provider (embedded FS or assets path) for the CLI's console version; if LoadTemplates fails, you get 'cannot fetch template'. Causes are a missing/corrupt embedded asset, an unreadable static asset directory, or a template path that doesn't exist.","triggerScenarios":"Starting `hasura console` (or an API server that builds the console router) when the embedded console assets for the pinned templateVersion can't be read, or the static assets directory was moved/removed, so LoadTemplates returns an error.","commonSituations":"Using a custom/old CLI build where console assets weren't embedded; pointing --static-dir to a non-existent path; upgrading the CLI with corrupted cached assets; disk/full or permission issues reading the embedded FS.","solutions":["Upgrade/reinstall the CLI binary so embedded console assets match the CLI version","If using --static-dir, verify the directory exists and contains the console assets","Clear any cached console assets the CLI uses and retry","Report/avoid patched CLI builds that strip the embed of template assets"],"exampleFix":"# before\nhasura console --static-dir ./missing-assets  # cannot fetch template\n\n# after\nhasura console --static-dir ./console-assets   # directory with valid assets","handlingStrategy":"try-catch","validationCode":"if staticDir != \"\" {\n    if info, err := os.Stat(staticDir); err != nil || !info.IsDir() {\n        return fmt.Errorf(\"static dir invalid: %s\", staticDir)\n    }\n}","typeGuard":null,"tryCatchPattern":"router, err := console.BuildConsoleRouter(...)\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot fetch template\") {\n        // reinstall/upgrade CLI binary to restore embedded assets\n    }\n}","preventionTips":["Use official CLI release binaries","Keep --static-dir pointing at a complete, existing assets dir","Re-download assets after CLI upgrades"],"tags":["console","template","assets","hasura"],"backgroundTag":"template-load-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}