{"record":{"id":"84ded948be98c436","repo":"googleapis/mcp-toolbox","slug":"failed-to-read-a-prebuilt-tool-w","errorCode":null,"errorMessage":"failed to read a prebuilt tool %w","messagePattern":"failed to read a prebuilt tool %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/prebuiltconfigs/prebuiltconfigs.go","lineNumber":77,"sourceCode":"}\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}\n\tif len(toolYAMLs) == 0 {\n\t\terrMsg := fmt.Errorf(\"no prebuilt tool configurations were loaded.%w\", err)\n\t\treturn nil, nil, errMsg\n\t}\n\n\treturn toolYAMLs, sourceTypes, nil\n}\n","sourceCodeStart":59,"sourceCodeEnd":93,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/prebuiltconfigs/prebuiltconfigs.go#L59-L93","documentation":"After listing the embedded tools directory, loadPrebuiltToolYAMLs reads each .yaml file with prebuiltConfigsFS.ReadFile. This error wraps a failure reading one specific embedded file — for embedded FSs this is rare (contents are in the binary) and usually indicates an inconsistent build or corrupted embed state.","triggerScenarios":"ReadFile fails on a file discovered by ReadDir — e.g. the entry vanished between listing and reading in a non-embedded (OS-dir) build variant, a directory named \"*.yaml\" passes the suffix check but can't be ReadFile'd, or path.Join produced an unexpected path.","commonSituations":"Someone committed a directory named like \"mydb.yaml/\" which IsDir()==false handling misses in odd builds; a modified FS wrapper in tests injecting a fake that lists but cannot serve files.","solutions":["Identify which file fails from the wrapped error and confirm it is a regular file under internal/prebuiltconfigs/tools/.","Remove/rename any directory or symlink whose name ends in .yaml.","Rebuild the binary to refresh embedded contents.","If a custom prebuiltConfigsFS is injected in tests, ensure it returns readable bytes for every listed entry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"content, err := prebuiltConfigsFS.ReadFile(filePathInFS)\nif err != nil {\n\treturn fmt.Errorf(\"failed to read a prebuilt tool %w (path=%s)\", err, filePathInFS)\n}","preventionTips":["Keep tools/ entries as regular .yaml files — never directories or symlinks with a .yaml name.","Rebuild binaries after modifying embedded assets; never mix stale binaries with new sources.","Include the failing path in error context when wrapping."],"tags":["embed","go","prebuilt-configs","filesystem"],"backgroundTag":"embedded-asset-read-failed","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"}