{"record":{"id":"f5d96ebb39f642c3","repo":"lima-vm/lima","slug":"identifier-q-greater-than-maximum-length-d-cha","errorCode":null,"errorMessage":"identifier %#q greater than maximum length (%d characters)","messagePattern":"identifier %#q greater than maximum length \\((.+?) characters\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/identifiers/validate.go","lineNumber":63,"sourceCode":")\n\n// identifierRe defines the pattern for valid identifiers.\nvar identifierRe = regexp.MustCompile(reAnchor(alphanum + reGroup(separators+reGroup(alphanum)) + \"*\"))\n\n// Validate returns nil if the string s is a valid identifier.\n//\n// Identifiers are similar to the domain name rules according to RFC 1035, section 2.3.1. However\n// rules in this package are relaxed to allow numerals to follow period (\".\") and mixed case is\n// allowed.\n//\n// In general identifiers that pass this validation should be safe for use as filesystem path components.\nfunc Validate(s string) error {\n\tif s == \"\" {\n\t\treturn errors.New(\"identifier must not be empty\")\n\t}\n\n\tif len(s) > maxLength {\n\t\treturn fmt.Errorf(\"identifier %#q greater than maximum length (%d characters)\", s, maxLength)\n\t}\n\n\tif !identifierRe.MatchString(s) {\n\t\treturn fmt.Errorf(\"identifier %#q must match %v\", s, identifierRe)\n\t}\n\treturn nil\n}\n\nfunc reGroup(s string) string {\n\treturn `(?:` + s + `)`\n}\n\nfunc reAnchor(s string) string {\n\treturn `^` + s + `$`\n}\n","sourceCodeStart":45,"sourceCodeEnd":79,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/identifiers/validate.go#L45-L79","documentation":"Validate checks that an identifier (instance name, disk name, etc.) is non-empty, within the maximum length, and matches the allowed character pattern. This error is returned when the string exceeds maxLength characters. Lima enforces a uniform identifier limit so names remain safe for use as file names, DNS-ish labels, and command arguments.","triggerScenarios":"Calling identifiers.Validate (directly or via ValidateInstName, InstNameFromYAMLPath, ValidateTemplateArgs, or DiskDir) with a string longer than maxLength, e.g. an instance name built from a long YAML path or a template arg like `limactl create --name=<very-long-name>`.","commonSituations":"Users deriving instance names from long file paths or hostnames; CI systems generating machine names from long branch/PR slugs; copying long UUIDs or template URLs as names.","solutions":["Shorten the identifier to at most maxLength characters (see pkg/identifiers/validate.go for the constant; historically 128)","Use `limactl create` with a shorter explicit --name instead of a derived path","If the name is generated, truncate or hash the long portion before passing it to Lima"],"exampleFix":"// before\nname := \"ci-\" + longBranchSlug // >128 chars\nerr := identifiers.ValidateInstName(name)\n// after\nif len(longBranchSlug) > 100 { longBranchSlug = longBranchSlug[:100] }\nname := \"ci-\" + longBranchSlug\nerr := identifiers.ValidateInstName(name)","handlingStrategy":"validation","validationCode":"func validIdentLen(s string) bool { return len(s) > 0 && len(s) <= 128 } // check before identifiers.Validate\nif !validIdentLen(name) { name = name[:128] }","typeGuard":"func isShortEnough(s string, max int) bool { return len(s) <= max }","tryCatchPattern":null,"preventionTips":["Truncate or hash generated names (branch slugs, paths) before passing to Lima","Keep instance names short and human-chosen","Validate names at config-load time, before VM creation"],"tags":["validation","identifier","lima"],"backgroundTag":"identifier-too-long","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}