{"id":"c85cd13765b2f5b2","repo":"docker/cli","slug":"invalid-label-s-empty-name","errorCode":null,"errorMessage":"invalid label '%s': empty name","messagePattern":"invalid label '(.+?)': empty name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/opts.go","lineNumber":243,"sourceCode":"\nconst whiteSpaces = \" \\t\"\n\n// 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,","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/opts.go#L225-L261","documentation":"Error \"invalid label '%s': empty name\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/opts.go:243 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}