{"record":{"id":"a663dc09986a4e73","repo":"googleapis/mcp-toolbox","slug":"doc-d-invalid-config-format-at-key-q-w","errorCode":null,"errorMessage":"doc %d: invalid config format at key %q: %w","messagePattern":"doc (.+?): invalid config format at key %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/config.go","lineNumber":279,"sourceCode":"\t\t\t\tswitch key {\n\t\t\t\tcase \"authServices\":\n\t\t\t\t\tkey = \"authService\"\n\t\t\t\tcase \"sources\":\n\t\t\t\t\tkey = \"source\"\n\t\t\t\tcase \"embeddingModels\":\n\t\t\t\t\tkey = \"embeddingModel\"\n\t\t\t\tcase \"tools\":\n\t\t\t\t\tkey = \"tool\"\n\t\t\t\tcase \"toolsets\":\n\t\t\t\t\tkey = \"toolset\"\n\t\t\t\tcase \"prompts\":\n\t\t\t\t\tkey = \"prompt\"\n\t\t\t\tcase \"groups\":\n\t\t\t\t\tkey = \"group\"\n\t\t\t\t}\n\t\t\t\ttransformed, err := transformDocs(key, slice)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"doc %d: invalid config format at key %q: %w\", docIndex, srcKey, err)\n\t\t\t\t}\n\t\t\t\t// encode per-doc\n\t\t\t\tfor _, doc := range transformed {\n\t\t\t\t\tif err := encoder.Encode(migrateToolsetKind(ctx, doc)); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"doc %d: invalid config format at key %q: expected nested format keys and type map\", docIndex, key)\n\t\t\t}\n\t\t}\n\t}\n\treturn buf.Bytes(), nil\n}\n\n// hasKindField is a helper function to check if an input is in flat format\nfunc hasKindField(input yaml.MapSlice) bool {\n\tfor _, item := range input {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/config.go#L261-L297","documentation":"ConvertConfig returns this when transforming a document section fails: a top-level key (e.g. 'sources', 'tools', 'prompts', 'groups') maps to a slice whose documents cannot be transformed by transformDocs into the flat format. It wraps the inner transform error with the doc index and source key for pinpointing the bad section.","triggerScenarios":"A legacy config section like `tools:` or `prompts:` contains a list of docs where an entry has an unexpected shape (missing expected fields/kind, wrong nesting), causing transformDocs to fail during ConvertConfig/runMigrate.","commonSituations":"Partially hand-migrated configs mixing old and new shapes per section; copy-pasted fragments from different toolbox versions; edits that removed required 'kind' or renamed fields.","solutions":["Follow the wrapped inner error to the exact doc and key; restore the expected nested keys and type map for that entry.","Ensure each entry has the required 'kind' field and correct fields for that kind.","Run the full migration command on the original legacy config rather than hand-editing.","Compare the failing section against a working example in current docs and align it."],"exampleFix":"# before: malformed tool entry\nprompts:\n  - name: greet\n# missing kind/body\n# after\nprompts:\n  - kind: prompt\n    name: greet\n    description: Greets the user\n    messages:\n      - content: \"Hello!\"","handlingStrategy":"validation","validationCode":"for _, e := range cfg.Tools {\n    if e[\"kind\"] == nil { log.Fatalf(\"tool entry missing 'kind': %v\", e) }\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"invalid config format at key\") {\n    log.Fatalf(\"fix the section named in the error (doc index + key provided): %v\", err)\n}","preventionTips":["Don't hand-migrate; always run the toolbox migration command on legacy files.","Keep every list entry with a 'kind' field and required parameters for that kind.","Diff edited configs against a known-good example before loading."],"tags":["config","migration","yaml","validation"],"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"}