lima-vm/lima · error
invalid value for static parameter: %#q
Error message
invalid value for static parameter: %#q
What it means
ParsePortForward parses a --port-forward flag value of the form HOST:GUEST or HOST:GUEST,static=true. When the optional second comma-separated segment starts with `static=`, the remainder must be a valid Go boolean (strconv.ParseBool accepts 1,0,t,f,true,false,TRUE,FALSE...). This error is returned when the text after `static=` is not parseable as a bool.
Source
Thrown at cmd/limactl/editflags/editflags.go:158
parts := strings.Split(spec, ",")
if len(parts) > 2 {
return "", "", false, fmt.Errorf("invalid port forward format %#q, expected HOST:GUEST or HOST:GUEST,static=true", spec)
}
portParts := strings.Split(strings.TrimSpace(parts[0]), ":")
if len(portParts) != 2 {
return "", "", false, fmt.Errorf("invalid port forward format %#q, expected HOST:GUEST", parts[0])
}
hostPort = strings.TrimSpace(portParts[0])
guestPort = strings.TrimSpace(portParts[1])
if len(parts) == 2 {
staticPart := strings.TrimSpace(parts[1])
if staticValue, ok := strings.CutPrefix(staticPart, "static="); ok {
isStatic, err = strconv.ParseBool(staticValue)
if err != nil {
return "", "", false, fmt.Errorf("invalid value for static parameter: %#q", staticValue)
}
} else {
return "", "", false, fmt.Errorf("invalid parameter %#q, expected `static=` followed by a boolean value", staticPart)
}
}
return hostPort, guestPort, isStatic, nil
}
func BuildPortForwardExpression(portForwards []string) (string, error) {
if len(portForwards) == 0 {
return "", nil
}
ports := make([]string, len(portForwards))
for i, spec := range portForwards {
hostPort, guestPort, isStatic, err := ParsePortForward(spec)
if err != nil {View on GitHub (pinned to dd909d0973)
Solutions
- Use a Go-parseable boolean: true/false/1/0/t/f/T/F/TRUE/FALSE (e.g. --port-forward 8080:80,static=true)
- Check for typos or whitespace in the value after static=
- If you need yes/no semantics, normalize the value before passing it in
Example fix
// before limactl create --port-forward '8080:80,static=yes' // after limactl create --port-forward '8080:80,static=true'
Defensive patterns
Strategy: validation
Validate before calling
func validStaticValue(v string) bool {
_, err := strconv.ParseBool(v)
return err == nil
}
// spec := "8080:80,static=true"
// if parts := strings.Split(spec, ","); len(parts) == 2 {
// if sv, ok := strings.CutPrefix(strings.TrimSpace(parts[1]), "static="); !ok || !validStaticValue(sv) {
// return fmt.Errorf("bad port-forward spec %q", spec)
// }
// } Type guard
func isParseableBool(s string) bool {
_, err := strconv.ParseBool(s)
return err == nil
} Try / catch
hostPort, guestPort, isStatic, err := editflags.ParsePortForward(spec)
if err != nil {
return fmt.Errorf("--port-forward %q rejected: %w (use HOST:GUEST[,static=true|false])", spec, err)
} Prevention
- Always use true/false (or 1/0) after static=, never yes/no/on/off
- Quote flag values in shell to avoid stray spaces
- Add a CLI-side validation or completion hint for the port-forward format
When it happens
Trigger: Calling ParsePortForward (directly or via BuildPortForwardExpression from limactl edit/create --port-forward) with a spec like '8080:80,static=yes', '8080:80,static=', or '8080:80,static=on' — any non-boolean value after static=.
Common situations: Users typing shell-style truthy words (yes/no/on/off) instead of Go booleans; typos like 'static=tue'; scripts interpolating empty variables producing 'static='; copying examples from other tools that use yes/no.
Related errors
- invalid parameter %#q, expected `static=` followed by a bool
- invalid port forward format %#q, expected HOST:GUEST or HOST
- invalid port forward format %#q, expected HOST:GUEST
- invalid parameter %#q, expected NAME=VALUE
- template does not define param %#q
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/58418b0773458df7.
Report an issue: GitHub.