lima-vm/lima · error

invalid parameter %#q, expected NAME=VALUE

Error message

invalid parameter %#q, expected NAME=VALUE

What it means

BuildParamExpressions converts --param flag values into yq expressions for template parameter overrides. Each value must be in NAME=VALUE form. This error is returned when a parameter string contains no '=' so no key/value pair can be extracted.

Source

Thrown at cmd/limactl/editflags/editflags.go:190

	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)
	}
	expr := fmt.Sprintf(".portForwards += [%s]", strings.Join(ports, ","))
	return expr, nil
}

func BuildParamExpressions(params []string, allowedParams map[string]string) ([]string, error) {
	exprs := make([]string, len(params))
	for i, param := range params {
		key, value, ok := strings.Cut(param, "=")
		if !ok {
			return nil, fmt.Errorf("invalid parameter %#q, expected NAME=VALUE", param)
		}
		if _, ok := allowedParams[key]; !ok {
			return nil, fmt.Errorf("template does not define param %#q", key)
		}
		exprs[i] = fmt.Sprintf(".param[%q] = %q", key, value)
	}
	return exprs, nil
}

func buildMountListExpression(ss []string) (string, error) {
	mounts := make([]string, len(ss))
	for i, s := range ss {
		writable := strings.HasSuffix(s, ":w")
		loc, err := localpathutil.Expand(strings.TrimSuffix(s, ":w"))
		if err != nil {
			return "", err
		}
		mounts[i] = fmt.Sprintf(`{"location": %q, "mountPoint": %q, "writable": %v}`, loc, loc, writable)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Pass the parameter as NAME=VALUE, e.g. --param cpuCount=4
  2. Quote the argument in the shell so '=' is not interpreted oddly: --param 'cpuCount=4'
  3. List the template's params (template must define the NAME too, see error 48)

Example fix

// before
limactl create template://_default --param cpuCount
// after
limactl create template://_default --param cpuCount=4
Defensive patterns

Strategy: validation

Validate before calling

func validParam(p string) bool {
	key, _, ok := strings.Cut(p, "=")
	return ok && key != ""
}
// for _, p := range params {
// 	if !validParam(p) { return fmt.Errorf("param %q must be NAME=VALUE", p) }
// }

Type guard

func isNameValue(s string) bool {
	_, _, ok := strings.Cut(s, "=")
	return ok
}

Try / catch

exprs, err := editflags.BuildParamExpressions(params, allowedParams)
if err != nil {
	return fmt.Errorf("bad --param argument: %w (expected NAME=VALUE)", err)
}

Prevention

When it happens

Trigger: Calling BuildParamExpressions (from limactl create/edit --param) with an entry lacking '=', e.g. --param 'cpuCount' or --param 'cpuCount:' instead of --param 'cpuCount=4'.

Common situations: Users passing just a parameter name forgetting the value; using ':' or space separators from other CLI conventions; shell variable expansion dropping the value so only 'NAME=' residue or 'NAME' remains.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/ed0672a5224d0964. Report an issue: GitHub.