{"record":{"id":"33557a092fe76d45","repo":"lima-vm/lima","slug":"invalid-port-forward-format-q-expected-host-gue-33557a","errorCode":null,"errorMessage":"invalid port forward format %#q, expected HOST:GUEST","messagePattern":"invalid port forward format %#q, expected HOST:GUEST","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/editflags/editflags.go","lineNumber":147,"sourceCode":"\tflags.String(\"audio-device\", \"\", commentPrefix+\"Audio device backend (e.g., 'pa', 'coreaudio', 'none')\")\n\tflags.String(\"audio-interface\", \"\", commentPrefix+\"Audio virtual hardware interface ('hda' or 'virtio')\")\n}\n\nfunc defaultExprFunc(expr string) func(v *flag.Flag) ([]string, error) {\n\treturn func(v *flag.Flag) ([]string, error) {\n\t\treturn []string{fmt.Sprintf(expr, v.Value)}, nil\n\t}\n}\n\nfunc ParsePortForward(spec string) (hostPort, guestPort string, isStatic bool, err error) {\n\tparts := strings.Split(spec, \",\")\n\tif len(parts) > 2 {\n\t\treturn \"\", \"\", false, fmt.Errorf(\"invalid port forward format %#q, expected HOST:GUEST or HOST:GUEST,static=true\", spec)\n\t}\n\n\tportParts := strings.Split(strings.TrimSpace(parts[0]), \":\")\n\tif len(portParts) != 2 {\n\t\treturn \"\", \"\", false, fmt.Errorf(\"invalid port forward format %#q, expected HOST:GUEST\", parts[0])\n\t}\n\n\thostPort = strings.TrimSpace(portParts[0])\n\tguestPort = strings.TrimSpace(portParts[1])\n\n\tif len(parts) == 2 {\n\t\tstaticPart := strings.TrimSpace(parts[1])\n\t\tif staticValue, ok := strings.CutPrefix(staticPart, \"static=\"); ok {\n\t\t\tisStatic, err = strconv.ParseBool(staticValue)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", \"\", false, fmt.Errorf(\"invalid value for static parameter: %#q\", staticValue)\n\t\t\t}\n\t\t} else {\n\t\t\treturn \"\", \"\", false, fmt.Errorf(\"invalid parameter %#q, expected `static=` followed by a boolean value\", staticPart)\n\t\t}\n\t}\n\n\treturn hostPort, guestPort, isStatic, nil","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/editflags/editflags.go#L129-L165","documentation":"Thrown by `ParsePortForward` when the first comma-separated segment of the port-forward spec does not split into exactly two `:`-separated parts. The HOST:GUEST portion must contain exactly one colon; zero or multiple colons (e.g. an IPv6 literal, or `8080` alone) fail with the offending segment quoted via `%#q`.","triggerScenarios":"Passing specs like `8080` (missing guest port), `127.0.0.1:8080:80` (host address with port plus a second colon) or `::1:8080` (unbracketed IPv6) to `limactl edit --port-forward` / `BuildPortForwardExpression`.","commonSituations":"Users supplying only a single port expecting lima to mirror it; trying to forward for a specific host IP (not supported by this flag); IPv6 hosts pasted unbracketed; whitespace typos.","solutions":["Provide both sides: `HOST:GUEST`, e.g. `8080:80` or `127.0.0.1:8080:80` -> use just `8080:80`.","For an IPv6 host address, bracket it so the split is unambiguous — if still unsupported by the flag, configure it in the YAML `portForwards` with `hostIP` instead.","To forward a specific host interface/IP, edit `portForwards[].hostIP` in the instance YAML rather than embedding the IP in this flag's spec.","Trim whitespace and ensure exactly one colon in the first segment before the comma."],"exampleFix":"// before\nlimactl edit myvm --port-forward '8080'            // missing :GUEST\nlimactl edit myvm --port-forward '127.0.0.1:8080:80' // too many colons\n\n// after\nlimactl edit myvm --port-forward '8080:80'","handlingStrategy":"validation","validationCode":"// Ensure the HOST:GUEST part has exactly one colon before invoking:\nfirst := strings.SplitN(spec, \",\", 2)[0]\nif strings.Count(strings.TrimSpace(first), \":\") != 1 {\n    return fmt.Errorf(\"HOST:GUEST must have exactly one colon, got %q\", first)\n}","typeGuard":null,"tryCatchPattern":"if err := runCmd(\"limactl\", \"edit\", inst, \"--port-forward\", spec); err != nil {\n    if strings.Contains(err.Error(), \"expected HOST:GUEST\") {\n        return fmt.Errorf(\"spec segment %q must be exactly HOST:GUEST with one colon\", strings.SplitN(spec, \",\", 2)[0])\n    }\n    return err\n}","preventionTips":["Always pass both host and guest ports: `8080:80`, never a single port.","Do not embed host IPs in the spec; configure hostIP in the YAML portForwards list instead.","For IPv6 hosts, remember the colon count pitfall — use the YAML config form rather than this flag."],"tags":["port-forward","cli","argument-parsing","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}