{"record":{"id":"9aac68adef1d8dbd","repo":"navidrome/navidrome","slug":"reading-types-rust-template-w","errorCode":null,"errorMessage":"reading types rust template: %w","messagePattern":"reading types rust template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/cmd/ndpgen/internal/generator.go","lineNumber":963,"sourceCode":"\n\ttmpl, err := template.New(\"types_stub\").Funcs(pdkFuncMap()).Parse(string(tmplContent))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing template: %w\", err)\n\t}\n\n\tvar buf bytes.Buffer\n\tif err := tmpl.Execute(&buf, symbols); err != nil {\n\t\treturn nil, fmt.Errorf(\"executing template: %w\", err)\n\t}\n\n\treturn buf.Bytes(), nil\n}\n\n// GenerateSharedTypesRust generates the nd-pdk-types crate root (lib.rs).\nfunc GenerateSharedTypesRust(structs []StructDef) ([]byte, error) {\n\ttmplContent, err := templatesFS.ReadFile(\"templates/types.rs.tmpl\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading types rust template: %w\", err)\n\t}\n\tsorted := sortedStructs(structs)\n\tknown := map[string]bool{}\n\tfor _, s := range sorted {\n\t\tknown[s.Name] = true\n\t}\n\ttmpl, err := template.New(\"types_rs\").Funcs(template.FuncMap{\n\t\t\"rustDocComment\":      RustDocComment,\n\t\t\"rustFieldName\":       func(n string) string { return ToSnakeCase(n) },\n\t\t\"fieldRustType\":       func(f FieldDef) string { return f.RustType(known) },\n\t\t\"skipSerializingFunc\": skipSerializingFunc,\n\t\t\"indent\":              indentSpaces,\n\t}).Parse(string(tmplContent))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing template: %w\", err)\n\t}\n\n\tpartialContent, err := templatesFS.ReadFile(\"templates/base64_bytes.rs.tmpl\")","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/navidrome/navidrome/blob/4ed7494a3293a9e9e647897ebfb9be327efd981b/plugins/cmd/ndpgen/internal/generator.go#L945-L981","documentation":"GenerateSharedTypesRust reads templates/types.rs.tmpl from the embedded templates FS before generating the nd-pdk-types crate root. This error wraps the FS ReadFile failure. It means the embedded template file is missing from the binary (or unreadable), not a Rust syntax problem.","triggerScenarios":"templatesFS.ReadFile(\"templates/types.rs.tmpl\") fails with os.ErrNotExist (or a read error) when GenerateSharedTypesRust is called — typically because the file was deleted/renamed or embed patterns exclude it.","commonSituations":"Renaming templates/types.rs.tmpl without updating the embedded FS path; an //go:embed pattern (e.g. embed templates/*.go.tmpl) that omits .rs.tmpl files; building from a partial checkout where template assets weren't committed.","solutions":["Confirm templates/types.rs.tmpl exists in plugins/cmd/ndpgen/internal/ and is spelled exactly that way.","Check the //go:embed directive covers all template files (e.g. embed templates/*) and rebuild.","git status / git checkout -- templates/types.rs.tmpl to restore a deleted file.","Run go build ./plugins/cmd/ndpgen/... to re-embed assets and retry generation."],"exampleFix":"// before\n//go:embed templates/*.go.tmpl\nvar templatesFS embed.FS\n\n// after\n//go:embed templates/*\nvar templatesFS embed.FS","handlingStrategy":"validation","validationCode":"// verify embedded assets before generating\nif _, err := templatesFS.ReadFile(\"templates/types.rs.tmpl\"); err != nil {\n    log.Fatalf(\"missing embedded template: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"out, err := GenerateSharedTypesRust(structs)\nif err != nil {\n    if errors.Is(err, os.ErrNotExist) || strings.Contains(err.Error(), \"reading types rust template\") {\n        return fmt.Errorf(\"ndpgen build is missing template assets; rebuild with `go build ./plugins/cmd/ndpgen/...`: %w\", err)\n    }\n    return err\n}","preventionTips":["Use a broad //go:embed templates/* directive.","Never gitignore internal/templates/*.tmpl files.","After adding/removing templates, rebuild the binary — embed is compile-time.","Check file names exactly match the ReadFile path constants."],"tags":["go","embed","template","codegen"],"backgroundTag":"missing-embedded-template","analyzedSha":"4ed7494a3293a9e9e647897ebfb9be327efd981b","analyzedAt":"2026-09-01T05:03:05.018Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}