{"record":{"id":"4d3f9ea30c8a85f4","repo":"XTLS/Xray-core","slug":"empty-http-header-value-key","errorCode":null,"errorMessage":"empty HTTP header value:  + key","messagePattern":"empty HTTP header value:  \\+ key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_method.go","lineNumber":125,"sourceCode":"\tif len(v.Version) > 0 {\n\t\tconfig.Version = &http.Version{Value: v.Version}\n\t}\n\n\tif len(v.Method) > 0 {\n\t\tconfig.Method = &http.Method{Value: v.Method}\n\t}\n\n\tif len(v.Path) > 0 {\n\t\tconfig.Uri = append([]string(nil), v.Path...)\n\t}\n\n\tif len(v.Headers) > 0 {\n\t\tconfig.Header = make([]*http.Header, 0, len(v.Headers))\n\t\theaderNames := sortMapKeys(v.Headers)\n\t\tfor _, key := range headerNames {\n\t\t\tvalue := v.Headers[key]\n\t\t\tif value == nil {\n\t\t\t\treturn nil, errors.New(\"empty HTTP header value: \" + key).AtError()\n\t\t\t}\n\t\t\tconfig.Header = append(config.Header, &http.Header{\n\t\t\t\tName:  key,\n\t\t\t\tValue: append([]string(nil), (*value)...),\n\t\t\t})\n\t\t}\n\t}\n\n\treturn config, nil\n}\n\ntype AuthenticatorResponse struct {\n\tVersion string                 `json:\"version\"`\n\tStatus  string                 `json:\"status\"`\n\tReason  string                 `json:\"reason\"`\n\tHeaders map[string]*StringList `json:\"headers\"`\n}\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_method.go#L107-L143","documentation":"Thrown while building an HTTP transport request config (HTTPTransportConfig.Build in transport_method.go): a key in the \"headers\" map has a nil value. Headers map from string to *[]string (json string array); JSON null (or a shape that unmarshals to nil) for any header triggers this error, which is decorated with .AtError() severity.","triggerScenarios":"\"headers\": { \"User-Agent\": null }\" under an http transport settings block (request path headers).","commonSituations":"Writing \"null\" for a header you want to remove instead of deleting the key; template engines (Helm/Jinja) rendering empty values as null; merging configs where a header override is absent and serialized as null.","solutions":["Replace the null value with an array of strings, e.g. \"User-Agent\": [\"curl/8\"] .","Or delete the header key entirely if the header should not be sent.","Check config-generation templates for conditionals that emit null."],"exampleFix":"// before\n\"headers\": { \"User-Agent\": null }\n// after\n\"headers\": { \"User-Agent\": [\"Mozilla/5.0\"] }","handlingStrategy":"validation","validationCode":"func httpRequestHeadersOK(ts map[string]any) bool {\n    req, _ := ts[\"request\"].(map[string]any)\n    headers, _ := req[\"headers\"].(map[string]any)\n    for _, v := range headers {\n        if v == nil { return false }\n        if _, ok := v.([]any); !ok { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"if err := buildHTTPTransport(raw); err != nil {\n    if strings.Contains(err.Error(), \"empty HTTP header value\") {\n        // the header name is appended to the message; fix that key\n    }\n    return err\n}","preventionTips":["Never use null for a header; delete the key instead.","In templates, render conditional headers only when a value exists (omit key otherwise).","Schema-validate that every headers value is an array of strings."],"tags":["go","xray","config","http","headers","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}