netbirdio/netbird · error
failed to parse MTU
Error message
failed to parse MTU: %w
What it means
The MTU token extracted from the ifconfig output is not a decimal integer, so strconv.Atoi failed while building the iface record. This indicates unexpected ifconfig output format; the parse is aborted rather than returning an iface with a zero or wrong MTU.
Solutions
- Inspect the mtu token in the ifconfig output
- Tolerate missing MTU with a default
- Log the malformed value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at client/iface/freebsd/iface.go:84 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/a9cf72c7a8bb1d34.
Report an issue: GitHub.
Appendix: source
Thrown at client/iface/freebsd/iface.go:84
}
// If line contains "inet ", it's a line with IP address
if strings.Contains(line, "inet ") {
parts := strings.Fields(line)
if len(parts) < 2 {
return nil, fmt.Errorf("failed to parse line: %s", line)
}
ips = append(ips, parts[1])
}
}
if name == "" {
return nil, fmt.Errorf("interface name not found in ifconfig output")
}
mtuInt, err := strconv.Atoi(mtu)
if err != nil {
return nil, fmt.Errorf("failed to parse MTU: %w", err)
}
return &iface{
Name: name,
MTU: mtuInt,
Group: group,
IPAddrs: ips,
}, nil
}
func parseIFName(output []byte) (string, error) {
// TODO: implement without allocations
lines := strings.Split(string(output), "\n")
if len(lines) == 0 || lines[0] == "" {
return "", fmt.Errorf("no output returned")
}
fields := strings.Fields(lines[0])View on GitHub (pinned to 93e97f4bf1)