{"id":"a94e563e3f7e1be6","repo":"docker/cli","slug":"variable-s-contains-whitespaces","errorCode":null,"errorMessage":"variable '%s' contains whitespaces","messagePattern":"variable '(.+?)' contains whitespaces","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/kvfile/kvfile.go","lineNumber":112,"sourceCode":"\t\t// trim the line from all leading whitespace first. trailing whitespace\n\t\t// is part of the value, and is kept unmodified.\n\t\tline := strings.TrimLeftFunc(string(scannedBytes), unicode.IsSpace)\n\n\t\tif len(line) == 0 || line[0] == '#' {\n\t\t\t// skip empty lines and comments (lines starting with '#')\n\t\t\tcontinue\n\t\t}\n\n\t\tkey, _, hasValue := strings.Cut(line, \"=\")\n\t\tif len(key) == 0 {\n\t\t\treturn []string{}, fmt.Errorf(\"no variable name on line '%s'\", line)\n\t\t}\n\n\t\t// leading whitespace was already removed from the line, but\n\t\t// variables are not allowed to contain whitespace or have\n\t\t// trailing whitespace.\n\t\tif strings.ContainsAny(key, whiteSpaces) {\n\t\t\treturn []string{}, fmt.Errorf(\"variable '%s' contains whitespaces\", key)\n\t\t}\n\n\t\tif hasValue {\n\t\t\t// key/value pair is valid and has a value; add the line as-is.\n\t\t\tlines = append(lines, line)\n\t\t\tcontinue\n\t\t}\n\n\t\tif lookupFn != nil {\n\t\t\t// No value given; try to look up the value. The value may be\n\t\t\t// empty but if no value is found, the key is omitted.\n\t\t\tif value, found := lookupFn(line); found {\n\t\t\t\tlines = append(lines, key+\"=\"+value)\n\t\t\t}\n\t\t}\n\t}\n\treturn lines, scanner.Err()\n}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/pkg/kvfile/kvfile.go#L94-L130","documentation":"Error \"variable '%s' contains whitespaces\" thrown in docker/cli.","triggerScenarios":"Thrown at pkg/kvfile/kvfile.go:112 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}