{"record":{"id":"11c4db00b8c5341f","repo":"googleapis/mcp-toolbox","slug":"error-parsing-argument-w","errorCode":null,"errorMessage":"error parsing argument: %w","messagePattern":"error parsing argument: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/prompts/arguments.go","lineNumber":45,"sourceCode":"type Argument struct {\n\tparameters.Parameter\n}\n\n// Arguments is a slice of Argument.\ntype Arguments []Argument\n\n// UnmarshalYAML provides custom unmarshaling logic for Arguments.\nfunc (args *Arguments) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error {\n\t*args = make(Arguments, 0)\n\tvar rawList []util.DelayedUnmarshaler\n\tif err := unmarshal(&rawList); err != nil {\n\t\treturn err\n\t}\n\n\tfor _, u := range rawList {\n\t\tvar p map[string]any\n\t\tif err := u.Unmarshal(&p); err != nil {\n\t\t\treturn fmt.Errorf(\"error parsing argument: %w\", err)\n\t\t}\n\n\t\t// If 'type' is missing, default it to string.\n\t\tparamType, ok := p[\"type\"]\n\t\tif !ok {\n\t\t\tp[\"type\"] = parameters.TypeString\n\t\t\tparamType = parameters.TypeString\n\t\t}\n\n\t\t// Call the clean, exported parser from the tools package. No more duplicated logic!\n\t\tparam, err := parameters.ParseParameter(ctx, p, paramType.(string))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t*args = append(*args, Argument{Parameter: param})\n\t}\n\treturn nil","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/prompts/arguments.go#L27-L63","documentation":"The custom UnmarshalYAML for prompt arguments expects each list item to be a map of parameter properties (name -> {type, description, ...}). It throws this error when an item in the arguments list cannot be unmarshaled into map[string]any — typically a scalar, string, or wrongly nested YAML value.","triggerScenarios":"A prompt's YAML `arguments:` list contains a plain string (e.g. `- name`) instead of a mapping (e.g. `- name: myparam\\n  type: string`), or the whole arguments block is a string rather than a list of maps.","commonSituations":"Hand-editing tools.yaml and forgetting the per-argument mapping; copying an older config format that used shorthand strings; indentation mistakes that turn a map into a scalar.","solutions":["Ensure every item under `arguments:` is a mapping with at least `name` (and optionally `type`, `description`).","Quote or reformat any shorthand string entries into proper YAML maps.","Validate YAML indentation so items are list entries of maps, not flattened strings.","Read the wrapped %w error to see the YAML node that failed to decode."],"exampleFix":"// before\narguments:\n  - name\n  - location\n// after\narguments:\n  - name: name\n    type: string\n    description: The name parameter\n  - name: location\n    type: string","handlingStrategy":"validation","validationCode":"// Validate prompt arguments shape before loading config\nfor i, arg := range cfg.PromptArguments {\n\tif arg == nil || len(arg.(map[string]any)) == 0 {\n\t\treturn fmt.Errorf(\"arguments[%d] must be a mapping with a 'name' field\", i)\n\t}\n}","typeGuard":null,"tryCatchPattern":"var p PromptConfig\nif err := yaml.Unmarshal(data, &p); err != nil {\n\tif strings.Contains(err.Error(), \"error parsing argument\") {\n\t\treturn fmt.Errorf(\"each arguments: entry must be a map like {name: ..., type: string}: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Always write arguments as a list of mappings with a `name` key.","Run YAML through a schema validator (yamllint + custom schema) before deploying configs.","Copy the canonical argument format from documentation, not from older shorthand formats."],"tags":["yaml","configuration","prompts","validation"],"backgroundTag":"yaml-config-parsing-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}