AdguardTeam/AdGuardHome · error
couldn't parse MAC address: %w
Error message
couldn't parse MAC address: %w
What it means
Converting a static-lease API payload (leaseStatic) to a Lease failed because HWAddr is not a parseable MAC address per net.ParseMAC. Raised in the HTTP layer when adding/updating a static lease.
Source
Thrown at internal/dhcpd/http_unix.go:103
func leasesToStatic(leases []*dhcpsvc.Lease) (static []*leaseStatic) {
static = make([]*leaseStatic, len(leases))
for i, l := range leases {
static[i] = &leaseStatic{
HWAddr: l.HWAddr.String(),
IP: l.IP,
Hostname: l.Hostname,
}
}
return static
}
// toLease converts leaseStatic to Lease or returns error.
func (l *leaseStatic) toLease() (lease *dhcpsvc.Lease, err error) {
addr, err := net.ParseMAC(l.HWAddr)
if err != nil {
return nil, fmt.Errorf("couldn't parse MAC address: %w", err)
}
return &dhcpsvc.Lease{
HWAddr: addr,
IP: l.IP,
Hostname: l.Hostname,
IsStatic: true,
}, nil
}
// leaseDynamic is the JSON form of dynamic DHCP lease.
type leaseDynamic struct {
HWAddr string `json:"mac"`
IP netip.Addr `json:"ip"`
Hostname string `json:"hostname"`
Expiry string `json:"expires"`
}
View on GitHub (pinned to b41aefbe51)
Solutions
- Supply the MAC in a standard format like aa:bb:cc:dd:ee:ff
- Double-check the field you are filling (HWAddr vs IP)
- Trim whitespace/newlines from pasted values
Example fix
// before
{"hwaddr": "192.168.1.50"}
// after
{"hwaddr": "aa:bb:cc:dd:ee:ff"} Defensive patterns
Strategy: type-guard
Validate before calling
if _, err := net.ParseMAC(req.HWAddr); err != nil { http.Error(w, "invalid MAC", 400); return } Type guard
func isValidMAC(s string) bool { _, err := net.ParseMAC(s); return err == nil } Try / catch
if _, err := net.ParseMAC(input); err != nil { /* 400 Bad Request, echo field name */ } Prevention
- Normalize/validate MAC client-side in forms
- Use placeholder format hints (aa:bb:cc:dd:ee:ff)
When it happens
Trigger: POSTing to the DHCP static-lease API (or UI form) with HWAddr empty, containing separators in the wrong places, invalid hex, or an IP address mistakenly supplied as the MAC.
Common situations: Typos in the UI form; pasting an IP into the MAC field; using unusual separator styles; sending already-normalized bytes instead of a string.
Related errors
- decoding json: %w
- parsing: %w
- parsing hardware address: %w
- subnet %s does not contain the ip %q
- %v is not an IPv4 %s
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/2eb4a4abd9653ae7.
Report an issue: GitHub.