{"id":"15a1007aa33989d1","repo":"docker/cli","slug":"failed-to-set-custom-headers-from-s-environment-v","errorCode":null,"errorMessage":"failed to set custom headers from %s environment variable: value contains a key=value pair with an empty key: '%s'","messagePattern":"failed to set custom headers from (.+?) environment variable: value contains a key=value pair with an empty key: '(.+?)'","errorType":"validation","errorClass":"errdefs.ErrInvalidParameter","httpStatus":null,"severity":"error","filePath":"cli/command/cli_options.go","lineNumber":196,"sourceCode":"\tif err != nil {\n\t\treturn nil, invalidParameter(fmt.Errorf(\n\t\t\t\"failed to parse custom headers from %s environment variable: value must be formatted as comma-separated key=value pairs\",\n\t\t\tenvOverrideHTTPHeaders,\n\t\t))\n\t}\n\tif len(fields) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tenv := map[string]string{}\n\tfor _, kv := range fields {\n\t\tk, v, hasValue := strings.Cut(kv, \"=\")\n\n\t\t// Only strip whitespace in keys; preserve whitespace in values.\n\t\tk = strings.TrimSpace(k)\n\n\t\tif k == \"\" {\n\t\t\treturn nil, invalidParameter(fmt.Errorf(\n\t\t\t\t`failed to set custom headers from %s environment variable: value contains a key=value pair with an empty key: '%s'`,\n\t\t\t\tenvOverrideHTTPHeaders, kv,\n\t\t\t))\n\t\t}\n\n\t\t// We don't currently allow empty key=value pairs, and produce an error.\n\t\t// This is something we could allow in future (e.g. to read value\n\t\t// from an environment variable with the same name). In the meantime,\n\t\t// produce an error to prevent users from depending on this.\n\t\tif !hasValue {\n\t\t\treturn nil, invalidParameter(fmt.Errorf(\n\t\t\t\t`failed to set custom headers from %s environment variable: missing \"=\" in key=value pair: '%s'`,\n\t\t\t\tenvOverrideHTTPHeaders, kv,\n\t\t\t))\n\t\t}\n\n\t\tenv[http.CanonicalHeaderKey(k)] = v\n\t}","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/cli_options.go#L178-L214","documentation":"Error \"failed to set custom headers from %s environment variable: value contains a key=value pair with an empty key: '%s'\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/cli_options.go:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}