{"record":{"id":"54eadd1629057710","repo":"googleapis/mcp-toolbox","slug":"failed-to-read-prebuilt-tools-w","errorCode":null,"errorMessage":"failed to read prebuilt tools %w","messagePattern":"failed to read prebuilt tools %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/prebuiltconfigs/prebuiltconfigs.go","lineNumber":67,"sourceCode":"\tcontent, ok := prebuiltToolYAMLs[prebuiltSourceConfig]\n\tif !ok {\n\t\tprebuiltHelpSuffix := \"no prebuilt configurations found.\"\n\t\tif len(prebuiltToolsSources) > 0 {\n\t\t\tprebuiltHelpSuffix = fmt.Sprintf(\"available: %s\", strings.Join(prebuiltToolsSources, \", \"))\n\t\t}\n\t\terrMsg := fmt.Errorf(\"prebuilt source tool for '%s' not found. %s\", prebuiltSourceConfig, prebuiltHelpSuffix)\n\t\treturn nil, errMsg\n\t}\n\treturn content, nil\n}\n\n// Load all available pre built tools\nfunc loadPrebuiltToolYAMLs() (map[string][]byte, []string, error) {\n\ttoolYAMLs := make(map[string][]byte)\n\tvar sourceTypes []string\n\tentries, err := prebuiltConfigsFS.ReadDir(\"tools\")\n\tif err != nil {\n\t\terrMsg := fmt.Errorf(\"failed to read prebuilt tools %w\", err)\n\t\treturn nil, nil, errMsg\n\t}\n\n\tfor _, entry := range entries {\n\t\tlowerName := strings.ToLower(entry.Name())\n\t\tif !entry.IsDir() && (strings.HasSuffix(lowerName, \".yaml\")) {\n\t\t\tfilePathInFS := path.Join(\"tools\", entry.Name())\n\t\t\tcontent, err := prebuiltConfigsFS.ReadFile(filePathInFS)\n\t\t\tif err != nil {\n\t\t\t\terrMsg := fmt.Errorf(\"failed to read a prebuilt tool %w\", err)\n\t\t\t\treturn nil, nil, errMsg\n\t\t\t}\n\t\t\tsourceTypeKey := entry.Name()[:len(entry.Name())-len(\".yaml\")]\n\n\t\t\tsourceTypes = append(sourceTypes, sourceTypeKey)\n\t\t\ttoolYAMLs[sourceTypeKey] = content\n\t\t}\n\t}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/prebuiltconfigs/prebuiltconfigs.go#L49-L85","documentation":"loadPrebuiltToolYAMLs reads the embedded filesystem directory \"tools\" (via embed.FS ReadDir) to discover all prebuilt configs. This error wraps any failure of that directory read, meaning the embedded FS is unreadable or the \"tools\" directory is missing from the build.","triggerScenarios":"prebuiltConfigsFS.ReadDir(\"tools\") fails because the embed directive is missing/empty (no tools/*.yaml matched at build time), the directory was renamed or deleted, or a build without the //go:embed assets was produced.","commonSituations":"Building a trimmed-down binary where the embed pattern matched nothing (Go errors at compile time, but a vendored/stale build may lack the dir); refactoring moved internal/prebuiltconfigs/tools/; running tests with a custom workspace excluding embedded assets.","solutions":["Verify internal/prebuiltconfigs/tools/ exists and contains at least one .yaml file matching the //go:embed pattern.","Rebuild with `go build` from a clean checkout so embed directives resolve.","Check go.mod/module path and working directory if running tests from an unexpected root.","Inspect the wrapped %w error for the underlying filesystem cause."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"toolYAMLs, sources, err := loadPrebuiltToolYAMLs()\nif err != nil {\n\treturn fmt.Errorf(\"prebuilt configs unavailable, falling back to explicit tool configs: %w\", err)\n}","preventionTips":["Keep the //go:embed tools/*.yaml directive and directory in sync after refactors.","Run `go build` in CI so missing embed patterns fail compilation, not runtime.","Never delete or rename internal/prebuiltconfigs/tools/ without updating embed patterns."],"tags":["embed","go","prebuilt-configs","filesystem"],"backgroundTag":"embedded-asset-missing","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}