{"id":"7ac1bb3bf2d35252","repo":"docker/cli","slug":"unexpected-environment-variable-s","errorCode":null,"errorMessage":"unexpected environment variable '%s'","messagePattern":"unexpected environment variable '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/loader.go","lineNumber":136,"sourceCode":"func buildEnvironment(env []string) (map[string]string, error) {\n\tresult := make(map[string]string, len(env))\n\tfor _, s := range env {\n\t\tif runtime.GOOS == \"windows\" && len(s) > 0 {\n\t\t\t// cmd.exe can have special environment variables which names start with \"=\".\n\t\t\t// They are only there for MS-DOS compatibility and we should ignore them.\n\t\t\t// See TestBuildEnvironment for examples.\n\t\t\t//\n\t\t\t// https://ss64.com/nt/syntax-variables.html\n\t\t\t// https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133\n\t\t\t// https://github.com/docker/cli/issues/4078\n\t\t\tif s[0] == '=' {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tk, v, ok := strings.Cut(s, \"=\")\n\t\tif !ok || k == \"\" {\n\t\t\treturn result, fmt.Errorf(\"unexpected environment variable '%s'\", s)\n\t\t}\n\t\t// value may be set, but empty if \"s\" is like \"K=\", not \"K\".\n\t\tresult[k] = v\n\t}\n\treturn result, nil\n}\n\nfunc loadConfigFiles(filenames []string, stdin io.Reader) ([]composetypes.ConfigFile, error) {\n\tconfigFiles := make([]composetypes.ConfigFile, 0, len(filenames))\n\n\tfor _, filename := range filenames {\n\t\tconfigFile, err := loadConfigFile(filename, stdin)\n\t\tif err != nil {\n\t\t\treturn configFiles, err\n\t\t}\n\t\tconfigFiles = append(configFiles, *configFile)\n\t}\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/stack/loader.go#L118-L154","documentation":"Error \"unexpected environment variable '%s'\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/stack/loader.go:136 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}