lima-vm/lima · error
identifier %#q greater than maximum length (%d characters)
Error message
identifier %#q greater than maximum length (%d characters)
What it means
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.
Source
Thrown at pkg/identifiers/validate.go:63
)
// identifierRe defines the pattern for valid identifiers.
var identifierRe = regexp.MustCompile(reAnchor(alphanum + reGroup(separators+reGroup(alphanum)) + "*"))
// Validate returns nil if the string s is a valid identifier.
//
// Identifiers are similar to the domain name rules according to RFC 1035, section 2.3.1. However
// rules in this package are relaxed to allow numerals to follow period (".") and mixed case is
// allowed.
//
// In general identifiers that pass this validation should be safe for use as filesystem path components.
func Validate(s string) error {
if s == "" {
return errors.New("identifier must not be empty")
}
if len(s) > maxLength {
return fmt.Errorf("identifier %#q greater than maximum length (%d characters)", s, maxLength)
}
if !identifierRe.MatchString(s) {
return fmt.Errorf("identifier %#q must match %v", s, identifierRe)
}
return nil
}
func reGroup(s string) string {
return `(?:` + s + `)`
}
func reAnchor(s string) string {
return `^` + s + `$`
}
View on GitHub (pinned to dd909d0973)
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
Example fix
// before
name := "ci-" + longBranchSlug // >128 chars
err := identifiers.ValidateInstName(name)
// after
if len(longBranchSlug) > 100 { longBranchSlug = longBranchSlug[:100] }
name := "ci-" + longBranchSlug
err := identifiers.ValidateInstName(name) Defensive patterns
Strategy: validation
Validate before calling
func validIdentLen(s string) bool { return len(s) > 0 && len(s) <= 128 } // check before identifiers.Validate
if !validIdentLen(name) { name = name[:128] } Type guard
func isShortEnough(s string, max int) bool { return len(s) <= max } Prevention
- 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
When it happens
Trigger: 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>`.
Common situations: 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.
Related errors
- invalid value for number of cpus, must be >= 0
- identifier %#q must match %v
- field `provision[%d].mode` cannot set skipDefaultDependencyR
- field `provision[%d].path` must not be empty when mode is %#
- field `provision[%d].path` must be an absolute path
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/f5d96ebb39f642c3.
Report an issue: GitHub.