{"id":"540b7c2b8cea6b30","repo":"docker/cli","slug":"failed-to-set-custom-headers-from-s-environment-v-540b7c","errorCode":null,"errorMessage":"failed to set custom headers from %s environment variable: missing \"=\" in key=value pair: '%s'","messagePattern":"failed to set custom headers from (.+?) environment variable: missing \"=\" in key=value pair: '(.+?)'","errorType":"validation","errorClass":"errdefs.ErrInvalidParameter","httpStatus":null,"severity":"error","filePath":"cli/command/cli_options.go","lineNumber":207,"sourceCode":"\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}\n\n\tif len(env) == 0 {\n\t\t// We should probably not hit this case, as we don't skip values\n\t\t// (only return errors), but we don't want to discard existing\n\t\t// headers with an empty set.\n\t\treturn nil, nil\n\t}\n\n\t// TODO(thaJeztah): add a client.WithExtraHTTPHeaders() function to allow these headers to be _added_ to existing ones, instead of _replacing_\n\t//  see https://github.com/docker/cli/pull/5098#issuecomment-2147403871  (when updating, also update the WARNING in the function and env-var GoDoc)\n\treturn client.WithHTTPHeaders(env), nil","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/cli_options.go#L189-L225","documentation":"Error \"failed to set custom headers from %s environment variable: missing \"=\" in key=value pair: '%s'\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/cli_options.go:207 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}