{"record":{"id":"61288d7db8c5249d","repo":"sipeed/picoclaw","slug":"invalid-header-q-name-cannot-be-empty","errorCode":null,"errorMessage":"invalid header %q: name cannot be empty","messagePattern":"invalid header %q: name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/helpers.go","lineNumber":251,"sourceCode":"\nfunc parseHeaderAssignments(values []string) (map[string]string, error) {\n\tif len(values) == 0 {\n\t\treturn nil, nil\n\t}\n\n\theaders := make(map[string]string, len(values))\n\tfor _, entry := range values {\n\t\tkey, value, found := strings.Cut(entry, \":\")\n\t\tif !found {\n\t\t\tkey, value, found = strings.Cut(entry, \"=\")\n\t\t}\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"invalid header %q: expected 'Name: Value' or 'Name=Value'\", entry)\n\t\t}\n\t\tkey = strings.TrimSpace(key)\n\t\tvalue = strings.TrimSpace(value)\n\t\tif key == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid header %q: name cannot be empty\", entry)\n\t\t}\n\t\theaders[key] = value\n\t}\n\n\treturn headers, nil\n}\n\nfunc looksLikeRemoteURL(target string) bool {\n\tparsedURL, err := url.ParseRequestURI(target)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif parsedURL.Host == \"\" {\n\t\treturn false\n\t}\n\tswitch strings.ToLower(parsedURL.Scheme) {\n\tcase \"http\", \"https\":\n\t\treturn true","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/helpers.go#L233-L269","documentation":"Second guard of parseHeaderAssignments (helpers.go:248-252): a separator was present but the name side trimmed to empty — ': value' or '=value'. The parser refuses to create a header with no name, even though the value may itself be empty.","triggerScenarios":"`-H \": x\"`, `-H \"=x\"`, or a whitespace-only name from a bad copy-paste where the real name landed before the opening quote.","commonSituations":"Retyping a header and dropping the name; snippet templates with a placeholder name left blank.","solutions":["Supply the header name before the separator: -H \"X-API-Key: value\"","Print the argument with printf '%s\\n' \"$H\" | cat -A to spot the empty/whitespace name"],"exampleFix":"# before\npicoclaw mcp add s https://api/x --transport http -H \": bearer\"\n# after\npicoclaw mcp add s https://api/x --transport http -H \"Authorization: bearer\"","handlingStrategy":"validation","validationCode":"validate_header() {\n  local h=$1 name\n  if [[ $h == *:* ]]; then name=${h%%:*}; else name=${h%%=*}; fi\n  [[ -n \"${name//[[:space:]]/}\" ]] || { echo \"header name empty in '$h'\" >&2; return 1; }\n}\nvalidate_header \"$h\" && picoclaw mcp add \"$name\" \"$url\" --transport http -H \"$h\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the header name before the separator","Validate templates/snippets that inject header values"],"tags":["cli","flags","http","headers"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}