{"record":{"id":"aa284fef2552470e","repo":"googleapis/mcp-toolbox","slug":"failed-to-initialize-resources-w-aa284f","errorCode":null,"errorMessage":"failed to initialize resources: %w","messagePattern":"failed to initialize resources: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/skills/command.go","lineNumber":272,"sourceCode":"\t}\n\tif group != \"\" {\n\t\treturn group, nil\n\t}\n\tif toolset != \"\" {\n\t\treturn toolset, nil\n\t}\n\tif len(prebuiltConfigs) == 1 {\n\t\treturn strings.ReplaceAll(prebuiltConfigs[0], \"/\", \"-\"), nil\n\t}\n\treturn \"\", fmt.Errorf(\"--name is required unless --group or --toolset is set, or exactly one --prebuilt config is provided\")\n}\n\nfunc (c *skillsCmd) collectContents(ctx context.Context, opts *internal.ToolboxOptions) (map[string]skillContent, error) {\n\t// Initialize tools and groups only; skills generation does not need live\n\t// sources, auth services, or embedding models.\n\ttoolsMap, groupsMap, err := server.InitializeOfflineConfigs(ctx, opts.Cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to initialize resources: %w\", err)\n\t}\n\n\treturn c.buildSkillContents(toolsMap, groupsMap)\n}\n\n// buildSkillContents maps each skill name to the tools and description it should\n// be generated with. In group mode, a group's own description takes precedence\n// over the --description flag, which acts as a fallback.\nfunc (c *skillsCmd) buildSkillContents(toolsMap map[string]tools.Tool, groupsMap map[string]group.Group) (map[string]skillContent, error) {\n\tprimitiveMgr := primitives.NewPrimitiveManager(nil, nil, nil, toolsMap, nil, groupsMap)\n\n\tskillsToContents := make(map[string]skillContent)\n\n\tgetToolsFromGroup := func(g group.Group) map[string]tools.Tool {\n\t\tgroupTools := make(map[string]tools.Tool)\n\t\tfor _, name := range g.ToolNames {\n\t\t\tif tool, ok := toolsMap[name]; ok {\n\t\t\t\tgroupTools[name] = tool","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/skills/command.go#L254-L290","documentation":"The `skills-generate` command wraps any failure from `server.InitializeOfflineConfigs` (which parses the toolbox config and instantiates tools and groups without connecting to live sources) with the message \"failed to initialize resources: %w\". It is a generic wrapper, so the underlying cause (YAML parse error, missing env var, invalid tool kind, bad group reference) is always included after it. It indicates the config file could not be turned into usable tool/group primitives for skill generation.","triggerScenarios":"Running `toolbox skills-generate` with a config file whose YAML fails to parse, references an unknown source kind/tool kind, contains an invalid tool definition, or references a group that fails to build; `InitializeOfflineConfigs(ctx, opts.Cfg)` in `collectContents` returns an error.","commonSituations":"Hand-edited YAML with wrong indentation; using a prebuilt config field that doesn't exist in the installed toolbox version; a tool requiring environment variables that resolve to invalid values; typos in `kind:` fields.","solutions":["Read the wrapped underlying error after \"failed to initialize resources:\" — it names the exact tool/source/group that failed","Validate the config YAML syntax with a linter (yamllint) or by loading it in another tool","Check that all referenced `kind:` values (sources, tools, groups) are supported by your toolbox version (`toolbox --version`)","Run `toolbox serve` or a config validation flow with the same file to reproduce and get richer logs"],"exampleFix":"// before: config.yaml references an unsupported tool kind\n// after: correct the kind or upgrade toolbox\n# tools:\n#   my-tool:\n#     kind: postgres-sql   # must match a registered tool kind\n#     source: my-pg\n#     statement: SELECT 1","handlingStrategy":"validation","validationCode":"// Validate the config before running skills-generate\nimport (\"os\"; \"gopkg.in/yaml.v3\")\nfunc configParses(path string) error {\n\tb, err := os.ReadFile(path)\n\tif err != nil { return err }\n\tvar m map[string]any\n\treturn yaml.Unmarshal(b, &m)\n}\n// if err := configParses(cfgPath); err != nil { fix before invoking }","typeGuard":null,"tryCatchPattern":"if err := collectContents(ctx, opts); err != nil {\n\tvar initErr error\n\tif errors.Unwrap(err) != nil { initErr = errors.Unwrap(err) }\n\tlog.Fatalf(\"resource init failed: %v (cause: %v)\", err, initErr)\n}","preventionTips":["Run `toolbox serve` (or a config validation pass) with the same file before skills-generate to catch init errors earlier","Lint YAML in CI before using configs","Pin toolbox versions when using prebuilt configs; check `kind:` values against your version's supported list","Keep environment variables for sources defined even for offline commands (they only need to parse)"],"tags":["go","config","initialization","toolbox-cli"],"backgroundTag":"config-initialization-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"}