{"record":{"id":"b4f89d0d5fed52c6","repo":"AdguardTeam/AdGuardHome","slug":"parsing-hardware-address-w","errorCode":null,"errorMessage":"parsing hardware address: %w","messagePattern":"parsing hardware address: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dhcpd/db.go","lineNumber":72,"sourceCode":"\t\t//\n\t\t// See https://github.com/AdguardTeam/AdGuardHome/issues/2692.\n\t\texpiryStr = l.Expiry.Format(time.RFC3339)\n\t}\n\n\treturn &dbLease{\n\t\tExpiry:   expiryStr,\n\t\tHostname: l.Hostname,\n\t\tHWAddr:   l.HWAddr.String(),\n\t\tIP:       l.IP,\n\t\tIsStatic: l.IsStatic,\n\t}\n}\n\n// toLease converts *dbLease to *dhcpsvc.Lease.\nfunc (dl *dbLease) toLease() (l *dhcpsvc.Lease, err error) {\n\tmac, err := net.ParseMAC(dl.HWAddr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing hardware address: %w\", err)\n\t}\n\n\texpiry := time.Time{}\n\tif !dl.IsStatic {\n\t\texpiry, err = time.Parse(time.RFC3339, dl.Expiry)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing expiry time: %w\", err)\n\t\t}\n\t}\n\n\treturn &dhcpsvc.Lease{\n\t\tExpiry:   expiry,\n\t\tIP:       dl.IP,\n\t\tHostname: dl.Hostname,\n\t\tHWAddr:   mac,\n\t\tIsStatic: dl.IsStatic,\n\t}, nil\n}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/db.go#L54-L90","documentation":"Converting a stored lease database record to an in-memory lease failed because the HWAddr field is not a parseable MAC address (net.ParseMAC error). The leases.json entries must contain hardware addresses in standard colon/hyphen/dot notation.","triggerScenarios":"Loading a leases.db/leases.json where a lease's HWAddr is empty, malformed (wrong digit count, invalid characters), or stored in an unsupported format.","commonSituations":"Corrupted lease DB after crash or disk issue; hand-edited lease files; lease DB written by an incompatible fork or version.","solutions":["Inspect the HWAddr values in the leases file and fix malformed entries to standard MAC format (aa:bb:cc:dd:ee:ff)","Delete or back up and remove the leases file to start fresh (leases will be re-acquired)","Restore from backup if the DB is corrupted"],"exampleFix":"// before\n{\"HWAddr\": \"192.168.1.5\"}\n// after\n{\"HWAddr\": \"aa:bb:cc:dd:ee:ff\"}","handlingStrategy":"validation","validationCode":"// before loading\nfor _, dl := range dbLeases {\n    if _, err := net.ParseMAC(dl.HWAddr); err != nil { /* skip or fix entry */ }\n}","typeGuard":"func isValidMAC(s string) bool { _, err := net.ParseMAC(s); return err == nil }","tryCatchPattern":null,"preventionTips":["Never hand-edit HWAddr fields","Back up leases file before upgrades"],"tags":["dhcp","leases","mac-address","persistence"],"backgroundTag":"corrupted-lease-database","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}