{"record":{"id":"6c417f9ac92489d0","repo":"lima-vm/lima","slug":"field-s-hostsocket-must-be-an-absolute-path-bu","errorCode":null,"errorMessage":"field `%s.hostSocket` must be an absolute path, but is %#q","messagePattern":"field `(.+?)\\.hostSocket` must be an absolute path, but is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":363,"sourceCode":"\t\t}\n\t\tif rule.GuestPortRange[0] > rule.GuestPortRange[1] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestPortRange[1]` must be greater than or equal to field `%s.guestPortRange[0]`\", field, field))\n\t\t}\n\t\tif rule.HostPortRange[0] > rule.HostPortRange[1] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostPortRange[1]` must be greater than or equal to field `%s.hostPortRange[0]`\", field, field))\n\t\t}\n\t\tif rule.GuestSocket != \"\" {\n\t\t\tif !path.IsAbs(rule.GuestSocket) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestSocket` must be an absolute path, but is %#q\", field, rule.GuestSocket))\n\t\t\t}\n\t\t\tif rule.HostSocket == \"\" && rule.HostPortRange[1]-rule.HostPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestSocket` can only be mapped to a single port or socket. not a range\", field))\n\t\t\t}\n\t\t}\n\t\tif rule.HostSocket != \"\" {\n\t\t\tif !filepath.IsAbs(rule.HostSocket) {\n\t\t\t\t// should be unreachable because FillDefault() will prepend the instance directory to relative names\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` must be an absolute path, but is %#q\", field, rule.HostSocket))\n\t\t\t}\n\t\t\tif rule.GuestSocket == \"\" && rule.GuestPortRange[1]-rule.GuestPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` can only be mapped from a single port or socket. not a range\", field))\n\t\t\t}\n\t\t} else if rule.GuestPortRange[1]-rule.GuestPortRange[0] != rule.HostPortRange[1]-rule.HostPortRange[0] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostPortRange` must specify the same number of ports as field `%s.guestPortRange`\", field, field))\n\t\t}\n\n\t\tif len(rule.HostSocket) >= osutil.UnixPathMax {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` must be less than UNIX_PATH_MAX=%d characters, but is %d\",\n\t\t\t\tfield, osutil.UnixPathMax, len(rule.HostSocket)))\n\t\t}\n\t\tswitch rule.Proto {\n\t\tcase limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny:\n\t\tdefault:\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.proto` must be %#q, %#q, or %#q\", field, limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny))\n\t\t}\n\t\tif rule.Reverse && rule.GuestSocket == \"\" {","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L345-L381","documentation":"hostSocket is a host filesystem path and must be absolute (filepath.IsAbs). The comment in the source notes this should normally be unreachable because FillDefault() prepends the instance directory to relative names, so hitting it usually means Validate was called without FillDefault or the path was malformed.","triggerScenarios":"Validate on a LimaYAML where portForwards[i].HostSocket is non-empty and relative — typically when Validate is invoked on a struct that skipped FillDefault, or in tests/custom tooling that builds LimaYAML directly.","commonSituations":"Programmatic use of the limayaml package that calls Validate before FillDefault; constructing LimaYAML in tests with relative socket paths; unusual paths that evade defaulting.","solutions":["Run FillDefault() on the LimaYAML before calling Validate","Replace the hostSocket with an absolute path (e.g. /home/user/.lima/instance/sock)","If using limactl normally, this is a bug indicator — check the lima version"],"exampleFix":"// before\ny, _ := limayaml.Load(b, \"f.yaml\")\nlimayaml.Validate(y, false)\n// after\ny, _ := limayaml.Load(b, \"f.yaml\")\nlimayaml.FillDefault(y)\nlimayaml.Validate(y, false)","handlingStrategy":"validation","validationCode":"for i, rule := range y.PortForwards {\n  if rule.HostSocket != \"\" && !filepath.IsAbs(rule.HostSocket) {\n    return fmt.Errorf(\"portForwards[%d]: hostSocket must be absolute\", i)\n  }\n}","typeGuard":"func hostSocketAbsolute(p string) bool { return p == \"\" || filepath.IsAbs(p) }","tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n  if strings.Contains(err.Error(), \"hostSocket` must be an absolute path\") {\n    // call limayaml.FillDefault(y) or absolutize the path\n  }\n}","preventionTips":["Always call FillDefault() before Validate when using the package programmatically","Store absolute hostSocket paths in templates","Treat this error in normal limactl usage as a bug report trigger"],"tags":["lima","port-forwarding","unix-socket","config-validation"],"backgroundTag":"socket-path-not-absolute","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}