{"record":{"id":"600c22fb211fd744","repo":"googleapis/mcp-toolbox","slug":"invalid-toolset-name-s","errorCode":null,"errorMessage":"invalid toolset name: %s","messagePattern":"invalid toolset name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/toolsets.go","lineNumber":96,"sourceCode":"\t\t}\n\t\ttoolsManifest[(*tool).GetName()] = m\n\t}\n\treturn ToolsetManifest{ServerVersion: t.Manifest.ServerVersion, ToolsManifest: toolsManifest}, nil\n}\n\nfunc (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool) (Toolset, error) {\n\t// finish toolset setup\n\t// Check each declared tool name exists\n\ttoolset := Toolset{\n\t\tToolsetConfig: t,\n\t\tTools:         make([]*Tool, 0, len(t.ToolNames)),\n\t\tManifest: ToolsetManifest{\n\t\t\tServerVersion: serverVersion,\n\t\t},\n\t\ttoolNameSet: make(map[string]struct{}, len(t.ToolNames)),\n\t}\n\tif !IsValidName(toolset.Name) {\n\t\treturn toolset, fmt.Errorf(\"invalid toolset name: %s\", toolset.Name)\n\t}\n\tfor _, toolName := range t.ToolNames {\n\t\ttool, ok := toolsMap[toolName]\n\t\tif !ok {\n\t\t\treturn toolset, fmt.Errorf(\"tool does not exist: %s\", toolName)\n\t\t}\n\t\ttoolset.Tools = append(toolset.Tools, &tool)\n\t\ttoolset.toolNameSet[toolName] = struct{}{}\n\t}\n\treturn toolset, nil\n}\n\nvar validName = regexp.MustCompile(`^[a-zA-Z0-9_-]*$`)\n\nfunc IsValidName(s string) bool {\n\treturn validName.MatchString(s)\n}\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/toolsets.go#L78-L114","documentation":"Toolset.Initialize validates the toolset's name against IsValidName (naming rules: allowed characters/format). If the toolset name is invalid, Initialize returns this error. Toolset names must follow the library's naming convention, otherwise the toolset cannot be registered or served.","triggerScenarios":"Calling Initialize (directly or via NewMockTool / toolset YAML parsing) with a Toolset whose Name fails IsValidName — e.g. empty name, spaces, uppercase, or special characters.","commonSituations":"Toolset key in YAML containing spaces or invalid characters; empty toolset name when constructing programmatically; kebab/snake case mismatch with validation rules.","solutions":["Rename the toolset to satisfy IsValidName (typically lowercase letters, digits, underscores/hyphens, non-empty)","Check the toolset key in the YAML config for stray whitespace or special characters","Inspect IsValidName in internal/tools/toolsets.go for the exact accepted pattern","Quote and re-check the name in the error message for hidden characters"],"exampleFix":"// before (tools.yaml)\ntoolsets:\n  \"My Toolset\":\n    - run_query\n// after\ntoolsets:\n  my_toolset:\n    - run_query","handlingStrategy":"validation","validationCode":"validName := regexp.MustCompile(`^[a-z0-9_]+$`)\nif !validName.MatchString(toolsetName) {\n    return fmt.Errorf(\"toolset name %q is invalid; use lowercase letters, digits, underscores\", toolsetName)\n}","typeGuard":null,"tryCatchPattern":"ts, err := t.Initialize(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid toolset name\") {\n        return fmt.Errorf(\"rename toolset: %w\", err)\n    }\n    return err\n}","preventionTips":["Use lowercase snake_case or kebab-case for toolset keys","Trim whitespace around YAML keys","Check IsValidName's rules before inventing new naming styles"],"tags":["go","validation","naming","toolset"],"backgroundTag":"invalid-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"}