netbirdio/netbird · error

parse interface name: %w

Error message

parse interface name: %w

What it means

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.

Source

Thrown at client/iface/freebsd/link.go:139

		return false, fmt.Errorf("link by name: %w", err)
	}

	return true, nil
}

func (l *Link) create(groupName string) (string, error) {
	cmd := exec.Command("ifconfig", groupName, "create")

	output, err := cmd.CombinedOutput()
	if err != nil {
		log.Debugf("ifconfig out: %s", output)

		return "", fmt.Errorf("create %s interface: %w", groupName, err)
	}

	interfaceName, err := parseIFName(output)
	if err != nil {
		return "", fmt.Errorf("parse interface name: %w", err)
	}

	return interfaceName, nil
}

func (l *Link) rename(oldName, newName string) (string, error) {
	cmd := exec.Command("ifconfig", oldName, "name", newName)

	output, err := cmd.CombinedOutput()
	if err != nil {
		log.Debugf("ifconfig out: %s", output)

		return "", fmt.Errorf("change name %q -> %q: %w", oldName, newName, err)
	}

	interfaceName, err := parseIFName(output)
	if err != nil {
		return "", fmt.Errorf("parse new name: %w", err)

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Run `ifconfig wg create` manually and inspect the byte-exact first line of output
  2. Ensure the real /usr/sbin/ifconfig is used with no wrappers or aliases on PATH
  3. Strip CR/whitespace from output before parsing if you maintain a fork
  4. As a workaround pattern, diff `ifconfig -l` snapshots taken before and after create to learn the new name

Example fix

// before
interfaceName, err := parseIFName(output)

// after (fallback: locate the freshly created wg* interface)
interfaceName, err := parseIFName(output)
if err != nil {
    interfaceName, err = diffInterfaceList(beforeList, afterList)
}
Defensive patterns

Strategy: fallback

Validate before calling

first := strings.SplitN(strings.TrimSpace(string(output)), "\n", 2)[0]
if fields := strings.Fields(first); len(fields) != 1 || fields[0] == "" {
    return fmt.Errorf("unexpected ifconfig create output: %q", first)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/3bcbeb0d005ad244. Report an issue: GitHub.