lima-vm/lima · error
invalid parameter %#q, expected `static=` followed by a bool
Error message
invalid parameter %#q, expected `static=` followed by a boolean value
What it means
ParsePortForward requires the optional second segment after the comma to be exactly `static=` followed by a boolean. This error is returned when the segment does not have the `static=` prefix at all (e.g. `8080:80,mode=tcp` or a stray comma).
Source
Thrown at cmd/limactl/editflags/editflags.go:161
}
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 {
return "", err
}
ports[i] = fmt.Sprintf(`{"guestPort": %q, "hostPort": %q, "static": %v}`, guestPort, hostPort, isStatic)View on GitHub (pinned to dd909d0973)
Solutions
- Use the exact syntax `static=true` or `static=false` as the second segment, e.g. '9090:9090,static=true'
- Remove extra commas or unknown parameters from the flag value
- Pass only HOST:GUEST if you do not need a static forward
Example fix
// before limactl create --port-forward '8080:80,static' // after limactl create --port-forward '8080:80,static=true'
Defensive patterns
Strategy: validation
Validate before calling
func validPortForwardSpec(spec string) error {
parts := strings.Split(spec, ",")
if len(parts) > 2 {
return fmt.Errorf("too many segments in %q", spec)
}
if !strings.Contains(parts[0], ":") {
return fmt.Errorf("expected HOST:GUEST in %q", spec)
}
if len(parts) == 2 {
p := strings.TrimSpace(parts[1])
if !strings.HasPrefix(p, "static=") {
return fmt.Errorf("second segment %q must be static=<bool>", p)
}
}
return nil
} Type guard
func hasStaticParam(part string) bool {
_, ok := strings.CutPrefix(strings.TrimSpace(part), "static=")
return ok
} Try / catch
_, _, _, err := editflags.ParsePortForward(spec)
if err != nil {
return fmt.Errorf("invalid --port-forward %q: %w (format: HOST:GUEST[,static=true])", spec, err)
} Prevention
- Use the documented syntax HOST:GUEST,static=true exactly
- Avoid trailing commas in scripted flag lists
- Do not invent extra parameters — only `static=` is supported in the second segment
When it happens
Trigger: Calling ParsePortForward / BuildPortForwardExpression with a spec whose second comma segment is not `static=<bool>`, e.g. '8080:80,static' (missing =), '8080:80,permanent=true', or '8080:80,' (trailing comma producing an empty segment).
Common situations: Users guessing the parameter name (writing 'static' without '=', or another flag name); trailing commas from scripted flag lists; copying syntax from other port-forwarding tools.
Related errors
- invalid value for static parameter: %#q
- 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/13f561f884ce36a1.
Report an issue: GitHub.