{"record":{"id":"05f17e44d10bcf47","repo":"AdguardTeam/AdGuardHome","slug":"reading-db-w","errorCode":null,"errorMessage":"reading db: %w","messagePattern":"reading db: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dhcpd/db.go","lineNumber":97,"sourceCode":"\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}\n\n// dbLoad loads stored leases.\nfunc (s *server) dbLoad() (err error) {\n\tdata, err := os.ReadFile(s.conf.dbFilePath)\n\tif err != nil {\n\t\tif !errors.Is(err, os.ErrNotExist) {\n\t\t\treturn fmt.Errorf(\"reading db: %w\", err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tdl := &dataLeases{}\n\terr = json.Unmarshal(data, dl)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"decoding db: %w\", err)\n\t}\n\n\tleases := dl.Leases\n\tleases4 := []*dhcpsvc.Lease{}\n\tleases6 := []*dhcpsvc.Lease{}\n\n\tfor _, l := range leases {\n\t\tvar lease *dhcpsvc.Lease\n\t\tlease, err = l.toLease()","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/db.go#L79-L115","documentation":"The DHCP server could not read the lease database file from disk; the wrapped error is an os.ReadFile failure other than 'file does not exist' (missing file is tolerated and treated as empty DB).","triggerScenarios":"Permission denied on the leases file, path is a directory, I/O errors, or the configured working directory containing an unreadable leases.db.","commonSituations":"Running the service as a user without read access to the data dir; SELinux/AppArmor restrictions; the file being replaced with a directory; disk failures.","solutions":["Check permissions on the leases file and data dir (chown/chmod so the service user can read)","Verify the path is a regular file, not a directory","Look for underlying I/O errors (dmesg/disk health) if permissions are fine"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight check\nif fi, err := os.Stat(path); err == nil && fi.IsDir() { return errors.New(\"leases path is a directory\") }","typeGuard":null,"tryCatchPattern":"if err := s.dbLoad(); err != nil { if errors.Is(err, os.ErrPermission) { /* fix perms / alert */ }; return err }","preventionTips":["Grant service user read/write on the data dir","Monitor for SELinux/AppArmor denials"],"tags":["dhcp","leases","filesystem","permissions"],"backgroundTag":"file-read-permission-denied","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}