{"id":"70400ebbb66d5fea","repo":"docker/cli","slug":"invalid-environment-variable-s","errorCode":null,"errorMessage":"invalid environment variable: %s","messagePattern":"invalid environment variable: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/env.go","lineNumber":21,"sourceCode":"import (\n\t\"errors\"\n\t\"os\"\n\t\"strings\"\n)\n\n// ValidateEnv validates an environment variable and returns it.\n// If no value is specified, it obtains its value from the current environment.\n//\n// Environment variable names are not validated, and it's up to the application\n// inside the container to validate them (see [moby-16585]). The only validation\n// here is to check if name is empty, per [moby-25099].\n//\n// [moby-16585]: https://github.com/moby/moby/issues/16585\n// [moby-25099]: https://github.com/moby/moby/issues/25099\nfunc ValidateEnv(val string) (string, error) {\n\tk, _, hasValue := strings.Cut(val, \"=\")\n\tif k == \"\" {\n\t\treturn \"\", errors.New(\"invalid environment variable: \" + val)\n\t}\n\tif hasValue {\n\t\t// val contains a \"=\" (but value may be an empty string)\n\t\treturn val, nil\n\t}\n\tif envVal, ok := os.LookupEnv(k); ok {\n\t\treturn k + \"=\" + envVal, nil\n\t}\n\treturn val, nil\n}\n","sourceCodeStart":3,"sourceCodeEnd":32,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/env.go#L3-L32","documentation":"Error \"invalid environment variable: %s\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/env.go:21 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}