{"record":{"id":"8081bb51d727ebf1","repo":"googleapis/mcp-toolbox","slug":"authservice-q-declared-more-than-once","errorCode":null,"errorMessage":"authService %q declared more than once","messagePattern":"authService %q declared more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/config.go","lineNumber":259,"sourceCode":"\t\t\t\tsourceConfigs = make(SourceConfigs)\n\t\t\t}\n\t\t\tif _, exists := sourceConfigs[name]; exists {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"source %q declared more than once\", name)\n\t\t\t}\n\t\t\tsourceConfigs[name] = c\n\t\tcase \"authService\":\n\t\t\tc, err := UnmarshalYAMLAuthServiceConfig(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 authServiceConfigs == nil {\n\t\t\t\tauthServiceConfigs = make(AuthServiceConfigs)\n\t\t\t}\n\t\t\tif _, exists := authServiceConfigs[name]; exists {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"authService %q declared more than once\", name)\n\t\t\t}\n\t\t\tauthServiceConfigs[name] = c\n\t\tcase \"tool\":\n\t\t\tc, err := UnmarshalYAMLToolConfig(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 c == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif toolConfigs == nil {\n\t\t\t\ttoolConfigs = make(ToolConfigs)\n\t\t\t}\n\t\t\tif _, exists := toolConfigs[name]; exists {\n\t\t\t\treturn nil, nil, nil, nil, nil, nil, fmt.Errorf(\"tool %q declared more than once\", name)","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/config.go#L241-L277","documentation":"Thrown by UnmarshalPrimitiveConfig when two documents declare an authService with the same 'name'. AuthServiceConfigs is keyed by name, so duplicates would overwrite; the parser rejects the config instead, mirroring the duplicate-source check.","triggerScenarios":"ParseConfig on a multi-document YAML file where two 'kind: authService' documents use the identical name string.","commonSituations":"Merging config files that each define an authService with the same name; templating emitting the auth block twice; copy-paste without renaming.","solutions":["Rename one authService so names are unique.","Delete the redundant duplicate document.","Reference the single authService by name from tools' authRequired instead of redeclaring it.","Grep the config file(s) for 'kind: authService' blocks and compare their names."],"exampleFix":"// before\nkind: authService\nname: myauth\n---\nkind: authService\nname: myauth\n// after\nkind: authService\nname: myauth\n---\nkind: authService\nname: myauth-alt","handlingStrategy":"validation","validationCode":"func checkUniqueAuthNames(docs []map[string]any) error {\n    seen := map[string]bool{}\n    for _, doc := range docs {\n        if k, _ := doc[\"kind\"].(string); k == \"authService\" {\n            n, _ := doc[\"name\"].(string)\n            if seen[n] {\n                return fmt.Errorf(\"authService %q declared more than once\", n)\n            }\n            seen[n] = true\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare each authService exactly once per file set; reference it by name elsewhere.","Use distinct names per environment when merging configs.","Add a CI uniqueness check for all resource kinds.","Avoid copy-pasting auth blocks between config files without renaming."],"tags":["yaml","config","duplicate","auth"],"backgroundTag":"duplicate-config-name","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"}