{"record":{"id":"dcd2177500542b8c","repo":"googleapis/mcp-toolbox","slug":"error-unmarshalling-http-method-s","errorCode":null,"errorMessage":"error unmarshalling HTTP method: %s","messagePattern":"error unmarshalling HTTP method: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/http_method.go","lineNumber":41,"sourceCode":"// HTTPMethod is a string of a valid HTTP method (e.g \"GET\")\ntype HTTPMethod string\n\n// isValidHTTPMethod checks if the input string matches one of the method constants defined in the net/http package\nfunc isValidHTTPMethod(method string) bool {\n\n\tswitch method {\n\tcase http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete,\n\t\thttp.MethodPatch, http.MethodHead, http.MethodOptions, http.MethodTrace,\n\t\thttp.MethodConnect:\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (i *HTTPMethod) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error {\n\tvar httpMethod string\n\tif err := unmarshal(&httpMethod); err != nil {\n\t\treturn fmt.Errorf(`error unmarshalling HTTP method: %s`, err)\n\t}\n\thttpMethod = strings.ToUpper(httpMethod)\n\tif !isValidHTTPMethod(httpMethod) {\n\t\treturn fmt.Errorf(`%s is not a valid http method`, httpMethod)\n\t}\n\t*i = HTTPMethod(httpMethod)\n\treturn nil\n}\n","sourceCodeStart":23,"sourceCodeEnd":50,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/http_method.go#L23-L50","documentation":"HTTPMethod has a custom YAML unmarshaler. This error wraps a lower-level failure that occurred while unmarshalling the method field into a string — e.g. the YAML node was not a scalar string (a map, list, or typed value), so the inner unmarshal call failed.","triggerScenarios":"A tools.yaml config sets the HTTP tool's method to a non-string YAML value, such as method: [get], method: {name: get}, or method: 200 (parsed as int in some flows), causing unmarshal(&httpMethod) to fail.","commonSituations":"Copy-pasted config with a list where a scalar was expected; YAML anchors/merge producing a mapping; quotes/typing issues where YAML infers a non-string type.","solutions":["Set method to a plain scalar string like method: get or method: GET","Remove any surrounding list/map structure around the method value","Validate the YAML config parses (yamllint or a quick Go yaml.Unmarshal) to spot the malformed node"],"exampleFix":"// before\nmethod:\n  - get\n// after\nmethod: get","handlingStrategy":"validation","validationCode":"node must be a scalar: verify the YAML value under `method` is a plain string before loading:\nif !reflect.DeepEqual(reflect.TypeOf(cfg.Method), reflect.TypeOf(\"\")) {\n    return errors.New(\"method must be a YAML string\")\n}","typeGuard":null,"tryCatchPattern":"var cfg ToolConfig\nif err := yaml.Unmarshal(data, &cfg); err != nil {\n    if strings.Contains(err.Error(), \"error unmarshalling HTTP method\") {\n        // fix the method field type in tools.yaml and reload\n    }\n    return err\n}","preventionTips":["Always write method as a plain scalar (method: GET) in tools.yaml","Run yamllint or a schema validator over tools.yaml before deployment","Avoid anchors/merge keys around the method field"],"tags":["yaml","configuration","unmarshalling","http"],"backgroundTag":"yaml-unmarshal-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"}