{"record":{"id":"01e40421c94c9526","repo":"netbirdio/netbird","slug":"link-by-name-w-01e404","errorCode":null,"errorMessage":"link by name: %w","messagePattern":"link by name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/freebsd/link.go","lineNumber":121,"sourceCode":"\treturn l.setAddr(ip, netmask)\n}\n\nfunc (l *Link) Up() error {\n\treturn l.up(l.name)\n}\n\nfunc (l *Link) Down() error {\n\treturn l.down(l.name)\n}\n\nfunc (l *Link) isExist() (bool, error) {\n\t_, err := LinkByName(l.name)\n\tif errors.Is(err, ErrDoesNotExist) {\n\t\treturn false, nil\n\t}\n\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"link by name: %w\", err)\n\t}\n\n\treturn true, nil\n}\n\nfunc (l *Link) create(groupName string) (string, error) {\n\tcmd := exec.Command(\"ifconfig\", groupName, \"create\")\n\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\tlog.Debugf(\"ifconfig out: %s\", output)\n\n\t\treturn \"\", fmt.Errorf(\"create %s interface: %w\", groupName, err)\n\t}\n\n\tinterfaceName, err := parseIFName(output)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"parse interface name: %w\", err)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/freebsd/link.go#L103-L139","documentation":"Returned by the FreeBSD link manager's isExist() when LinkByName() fails with any error other than ErrDoesNotExist. LinkByName shells out to `ifconfig <name>` and maps an output containing 'does not exist' to ErrDoesNotExist, which is handled as a normal negative result; every other failure is wrapped here. It means the existence check itself broke (helper missing, output unparseable, permission denied), not that the interface is absent.","triggerScenarios":"Calling Link.Recreate()/Add()/Del() (they start with isExist) when `ifconfig <name>` exits non-zero without 'does not exist' in its output: ifconfig missing from the daemon PATH (exec error with empty output), unprivileged run, or ifconfig output that parseIfconfigOutput cannot parse (no ': flags' line, bad MTU field).","commonSituations":"Agent in a jail, container, or minimal FreeBSD install without /usr/sbin in PATH; a service manager that strips the root PATH; localized ifconfig messages that no longer contain the literal 'does not exist'; stale interface name from a crashed run.","solutions":["Verify ifconfig is reachable by the daemon: check the service PATH includes /usr/sbin and run `which ifconfig`","Run the agent as root so ifconfig queries cannot fail on privileges","Reproduce manually with `ifconfig <ifaceName>` and confirm standard English output","Set LC_ALL=C in the daemon environment so output parsing is stable","Restart the agent so Recreate() retries with a fixed environment"],"exampleFix":"# before (service with stripped PATH)\n[Service]\nEnvironment=\"PATH=/bin\"\n\n# after\n[Service]\nEnvironment=\"PATH=/sbin:/usr/sbin:/bin:/usr/bin\"","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"ifconfig\"); err != nil {\n    return fmt.Errorf(\"ifconfig not in daemon PATH: %w\", err)\n}\nif _, err := freebsd.LinkByName(\"lo0\"); err != nil {\n    return fmt.Errorf(\"ifconfig not usable in this environment: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"ok, err := link.Recreate()\nif err != nil {\n    if strings.Contains(err.Error(), \"link by name\") {\n        // environment failure (PATH/privileges/output format), not a missing interface\n        return fmt.Errorf(\"fix ifconfig availability: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep /usr/sbin in the daemon's PATH","Pin LC_ALL=C for the netbird service on FreeBSD so ifconfig output parsing stays stable","Smoke-test `ifconfig <name>` after OS upgrades because the parser depends on output format"],"tags":["go","freebsd","ifconfig","interface","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}