{"record":{"id":"d15c2d5bd79733a6","repo":"googleapis/mcp-toolbox","slug":"error-converting-config-file-s","errorCode":null,"errorMessage":"error converting config file: %s","messagePattern":"error converting config file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/config.go","lineNumber":199,"sourceCode":"\t\t} else {\n\t\t\tcolumn++\n\t\t}\n\t}\n\treturn line, column\n}\n\nfunc (p *ConfigParser) ParseConfig(ctx context.Context, raw []byte) (Config, error) {\n\tvar config Config\n\t// Replace environment variables if found\n\toutput, err := p.parseEnv(string(raw))\n\tif err != nil {\n\t\treturn config, fmt.Errorf(\"error parsing environment variables: %s\", err)\n\t}\n\traw = []byte(output)\n\n\traw, err = ConvertConfig(ctx, raw)\n\tif err != nil {\n\t\treturn config, fmt.Errorf(\"error converting config file: %s\", err)\n\t}\n\n\t// Parse contents\n\tconfig.Sources, config.AuthServices, config.EmbeddingModels, config.Tools, config.Prompts, config.Groups, err = server.UnmarshalPrimitiveConfig(ctx, raw)\n\tif err != nil {\n\t\treturn config, err\n\t}\n\treturn config, nil\n}\n\n// ConvertConfig converts configuration file to flat format and rewrites toolsets\n// to the group kind.\nfunc ConvertConfig(ctx context.Context, raw []byte) ([]byte, error) {\n\tvar buf bytes.Buffer\n\t// Manually copy top-level comments and empty lines from the source\n\tscanner := bufio.NewScanner(bytes.NewReader(raw))\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/config.go#L181-L217","documentation":"ParseConfig wraps any error from ConvertConfig with this message. ConvertConfig migrates legacy/nested config formats to the current flat format (YAML stream of docs); failure means the config file is structurally incompatible or malformed for migration, so parsing aborts. The inner error carries the doc index and offending key.","triggerScenarios":"Loading a config written in an older toolbox format (nested toolsets/kinds) that ConvertConfig cannot transform — e.g. a doc with non-string keys, or a key whose value is not the expected nested keys-and-type map.","commonSituations":"Upgrading from an old toolbox version whose YAML layout changed; hand-editing a config and breaking the expected structure; copying fragments between configs with mismatched formats.","solutions":["Inspect the wrapped inner error ('doc %d: ... at key %q') and fix the structure at that key to the current format.","Run the migration command (toolbox migrate / runMigrate path) to convert the legacy config, then use the converted file.","Rewrite the config in the current flat format per current documentation examples.","Validate the YAML parses and all top-level keys (sources, tools, etc.) map string keys to proper maps."],"exampleFix":"# before: nested legacy config\nsources:\n  my-pg:\n    kind: postgres\n    # ...\ntoolsets:\n  default:\n    toolsets: []\n# after: run migration or write flat format\n# toolbox migrate --in tools.yaml --out tools.flat.yaml\n# tools.flat.yaml contains per-doc stream: sources, tools, ... in current schema","handlingStrategy":"validation","validationCode":"// smoke-test config load before deploy\ncfg, err := parser.ParseConfig(ctx, raw)\nif err != nil { log.Fatalf(\"config invalid: %v\", err) }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"error converting config file\") {\n    // inner error gives doc index and key; fix or re-run toolbox migrate on the source file\n    log.Fatalf(\"run `toolbox migrate` on the legacy config: %v\", err)\n}","preventionTips":["Run the migration command once on legacy configs and commit the converted output.","Validate configs in CI by loading them with ParseConfig on every change.","Pin the toolbox version per environment so config format and binary stay in sync."],"tags":["config","migration","format","startup"],"backgroundTag":"config-format-migration-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"}