{"record":{"id":"c0f22697a9f7aa9b","repo":"googleapis/mcp-toolbox","slug":"prompt-q-declared-more-than-once","errorCode":null,"errorMessage":"prompt %q declared more than once","messagePattern":"prompt %q declared more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/config.go","lineNumber":322,"sourceCode":"\t\t\t\tembeddingModelConfigs = make(EmbeddingModelConfigs)\n\t\t\t}\n\t\t\tif _, exists := embeddingModelConfigs[name]; exists {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"embeddingModel %q declared more than once\", name)\n\t\t\t}\n\t\t\tembeddingModelConfigs[name] = c\n\t\tcase \"prompt\":\n\t\t\tc, err := UnmarshalYAMLPromptConfig(ctx, name, resource)\n\t\t\tif err != nil {\n\t\t\t\tif len(file.Docs) > 1 {\n\t\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"document %d: error unmarshaling %s %q: %w\", docIndex, kind, name, err)\n\t\t\t\t}\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"error unmarshaling %s: %w\", kind, err)\n\t\t\t}\n\t\t\tif promptConfigs == nil {\n\t\t\t\tpromptConfigs = make(PromptConfigs)\n\t\t\t}\n\t\t\tif _, exists := promptConfigs[name]; exists {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"prompt %q declared more than once\", name)\n\t\t\t}\n\t\t\tpromptConfigs[name] = c\n\t\tcase \"group\":\n\t\t\tc, err := UnmarshalYAMLGroupConfig(ctx, name, resource)\n\t\t\tif err != nil {\n\t\t\t\tif len(file.Docs) > 1 {\n\t\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"document %d: error unmarshaling %s %q: %w\", docIndex, kind, name, err)\n\t\t\t\t}\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"error unmarshaling %s: %w\", kind, err)\n\t\t\t}\n\t\t\tif groupConfigs == nil {\n\t\t\t\tgroupConfigs = make(GroupConfigs)\n\t\t\t}\n\t\t\tif _, exists := groupConfigs[name]; exists {\n\t\t\t\tif name == \"\" {\n\t\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"more than one default (nameless) group declared; only one is allowed\")\n\t\t\t\t}\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"group %q declared more than once\", name)","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/config.go#L304-L340","documentation":"ParseConfig rejects a toolbox YAML file in which two prompt resources share the same name, because prompt configs are stored in a name-keyed map and duplicates are ambiguous. Before inserting a decoded prompt into promptConfigs, UnmarshalPrimitiveConfig checks for an existing key and fails with this message.","triggerScenarios":"A single YAML config (or multi-doc file) declares two 'prompt' entries with identical kindKind/name keys; ParseConfig hits the exists check at internal/server/config.go:322.","commonSituations":"Copy-pasting a prompt block and forgetting to rename it; merging two config files that both define the same prompt; generating YAML from a script that appends duplicate prompts.","solutions":["Search the YAML for duplicate prompt names and rename one of them","If merging files, deduplicate prompt keys before concatenating","If both prompts are intended to be distinct, give each a unique name"],"exampleFix":"# before\nprompts:\n  greet: {description: \"a\"}\n  greet: {description: \"b\"}\n# after\nprompts:\n  greet-en: {description: \"a\"}\n  greet-es: {description: \"b\"}","handlingStrategy":"validation","validationCode":"// Detect duplicate prompt keys before parsing\ntext, _ := os.ReadFile(path)\nseen := map[string]bool{}\nfor _, m := range regexp.MustCompile(`(?m)^\\s{2}([\\w-]+):`).FindAllStringSubmatch(string(text), -1) {\n\tname := m[1]\n\tif seen[name] {\n\t\tfmt.Printf(\"duplicate prompt key: %s\\n\", name)\n\t}\n\tseen[name] = true\n}","typeGuard":null,"tryCatchPattern":"if _, _, _, _, _, _, err := server.ParseConfig(ctx, cfg); err != nil {\n\tif strings.Contains(err.Error(), \"declared more than once\") {\n\t\tlog.Fatalf(\"duplicate resource name in config: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Adopt unique naming conventions for prompts (e.g. team-prompt-purpose)","When merging config files, run a key-duplication check script","Never copy-paste prompt blocks without renaming"],"tags":["yaml","config","duplicate","prompt"],"backgroundTag":"duplicate-config-key","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"}