{"id":"f34322be98d9ab6e","repo":"docker/cli","slug":"label-s-contains-whitespaces","errorCode":null,"errorMessage":"label '%s' contains whitespaces","messagePattern":"label '(.+?)' contains whitespaces","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/opts.go","lineNumber":246,"sourceCode":"// ValidateLabel validates that the specified string is a valid label, and returns it.\n//\n// Labels are in the form of key=value; key must be a non-empty string, and not\n// contain whitespaces. A value is optional (defaults to an empty string if omitted).\n//\n// Leading whitespace is removed during validation but values are kept as-is\n// otherwise, so any string value is accepted for both, which includes whitespace\n// (for values) and quotes (surrounding, or embedded in key or value).\n//\n// TODO discuss if quotes (and other special characters) should be valid or invalid for keys\n// TODO discuss if leading/trailing whitespace in keys should be preserved (and valid)\nfunc ValidateLabel(value string) (string, error) {\n\tkey, _, _ := strings.Cut(value, \"=\")\n\tkey = strings.TrimLeft(key, whiteSpaces)\n\tif key == \"\" {\n\t\treturn \"\", fmt.Errorf(\"invalid label '%s': empty name\", value)\n\t}\n\tif strings.ContainsAny(key, whiteSpaces) {\n\t\treturn \"\", fmt.Errorf(\"label '%s' contains whitespaces\", key)\n\t}\n\treturn value, nil\n}\n\n// ValidateSysctl validates a sysctl and returns it.\nfunc ValidateSysctl(val string) (string, error) {\n\tvalidSysctlMap := map[string]bool{\n\t\t\"kernel.msgmax\":          true,\n\t\t\"kernel.msgmnb\":          true,\n\t\t\"kernel.msgmni\":          true,\n\t\t\"kernel.sem\":             true,\n\t\t\"kernel.shmall\":          true,\n\t\t\"kernel.shmmax\":          true,\n\t\t\"kernel.shmmni\":          true,\n\t\t\"kernel.shm_rmid_forced\": true,\n\t}\n\tvalidSysctlPrefixes := []string{\n\t\t\"net.\",","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/opts.go#L228-L264","documentation":"Error \"label '%s' contains whitespaces\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/opts.go:246 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}