{"record":{"id":"3bcbeb0d005ad244","repo":"netbirdio/netbird","slug":"parse-interface-name-w","errorCode":null,"errorMessage":"parse interface name: %w","messagePattern":"parse interface name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/freebsd/link.go","lineNumber":139,"sourceCode":"\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)\n\t}\n\n\treturn interfaceName, nil\n}\n\nfunc (l *Link) rename(oldName, newName string) (string, error) {\n\tcmd := exec.Command(\"ifconfig\", oldName, \"name\", newName)\n\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\tlog.Debugf(\"ifconfig out: %s\", output)\n\n\t\treturn \"\", fmt.Errorf(\"change name %q -> %q: %w\", oldName, newName, err)\n\t}\n\n\tinterfaceName, err := parseIFName(output)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"parse new name: %w\", err)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/freebsd/link.go#L121-L157","documentation":"After `ifconfig wg create` succeeds, create() parses the combined output with parseIFName, which requires the first output line to be exactly one whitespace-separated token (the created name, e.g. 'wg0'); it fails with 'no output returned' or 'invalid output' otherwise. This error means the interface was created but its name could not be recovered from the command output.","triggerScenarios":"ifconfig prints an empty first line or more than one token on the first line: a wrapper script echoing banners around ifconfig, unexpected output format on the running FreeBSD version, or CRLF artifacts creating extra fields.","commonSituations":"Shimmed or wrapped ifconfig on the daemon PATH; nonstandard output after an OS update; jail environments redirecting command output; trailing carriage returns making a second token.","solutions":["Run `ifconfig wg create` manually and inspect the byte-exact first line of output","Ensure the real /usr/sbin/ifconfig is used with no wrappers or aliases on PATH","Strip CR/whitespace from output before parsing if you maintain a fork","As a workaround pattern, diff `ifconfig -l` snapshots taken before and after create to learn the new name"],"exampleFix":"// before\ninterfaceName, err := parseIFName(output)\n\n// after (fallback: locate the freshly created wg* interface)\ninterfaceName, err := parseIFName(output)\nif err != nil {\n    interfaceName, err = diffInterfaceList(beforeList, afterList)\n}","handlingStrategy":"fallback","validationCode":"first := strings.SplitN(strings.TrimSpace(string(output)), \"\\n\", 2)[0]\nif fields := strings.Fields(first); len(fields) != 1 || fields[0] == \"\" {\n    return fmt.Errorf(\"unexpected ifconfig create output: %q\", first)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep ifconfig unshimmed on the daemon PATH","Treat create-output parsing as fragile: prefer diffing `ifconfig -l` snapshots before and after create","Trim CR and whitespace from subprocess output before tokenizing"],"tags":["go","freebsd","ifconfig","parsing"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}