{"id":"5507b510ad014fb0","repo":"docker/cli","slug":"failed-to-parse-custom-headers-from-s-environment","errorCode":null,"errorMessage":"failed to parse custom headers from %s environment variable: value must be formatted as comma-separated key=value pairs","messagePattern":"failed to parse custom headers from (.+?) environment variable: value must be formatted as comma-separated key=value pairs","errorType":"validation","errorClass":"errdefs.ErrInvalidParameter","httpStatus":null,"severity":"error","filePath":"cli/command/cli_options.go","lineNumber":179,"sourceCode":"// environment variable is the equivalent to the HttpHeaders field in the\n// configuration file.\n//\n// WARNING: If both config and environment-variable are set, the environment-\n// variable currently overrides all headers set in the configuration file.\n// This behavior may change in a future update, as we are considering the\n// environment-variable to be appending to existing headers (and to only\n// override headers with the same name).\n//\n// TODO(thaJeztah): this is a client Option, and should be moved to the client. It is non-exported for that reason.\nfunc withCustomHeadersFromEnv() (client.Opt, error) {\n\tvalue := os.Getenv(envOverrideHTTPHeaders)\n\tif value == \"\" {\n\t\treturn nil, nil\n\t}\n\tcsvReader := csv.NewReader(strings.NewReader(value))\n\tfields, err := csvReader.Read()\n\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'`,","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/cli_options.go#L161-L197","documentation":"Error \"failed to parse custom headers from %s environment variable: value must be formatted as comma-separated key=value pairs\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/cli_options.go:179 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}