{"record":{"id":"3e0019e7f0bda718","repo":"AdguardTeam/AdGuardHome","slug":"init-querylog-w","errorCode":null,"errorMessage":"init querylog: %w","messagePattern":"init querylog: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/dns.go","lineNumber":102,"sourceCode":"\t\tHTTPReg:           httpReg,\n\t\tFindClient:        globalContext.clients.findMultiple,\n\t\tBaseDir:           querylogDir,\n\t\tAnonymizeClientIP: config.DNS.AnonymizeClientIP,\n\t\tRotationIvl:       time.Duration(config.QueryLog.Interval),\n\t\tMemSize:           config.QueryLog.MemSize,\n\t\tEnabled:           config.QueryLog.Enabled,\n\t\tFileEnabled:       config.QueryLog.FileEnabled,\n\t}\n\n\tengine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored, config.QueryLog.IgnoredEnabled)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"querylog: ignored list: %w\", err)\n\t}\n\n\tconf.Ignored = engine\n\tglobalContext.queryLog, err = querylog.New(conf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"init querylog: %w\", err)\n\t}\n\n\tglobalContext.filters, err = filtering.New(config.Filtering, nil)\n\tif err != nil {\n\t\t// Don't wrap the error, since it's informative enough as is.\n\t\treturn err\n\t}\n\n\tparams := dnsforward.DNSCreateParams{\n\t\tLogger:      baseLogger,\n\t\tDNSFilter:   globalContext.filters,\n\t\tStats:       globalContext.stats,\n\t\tQueryLog:    globalContext.queryLog,\n\t\tPrivateNets: parseSubnetSet(config.DNS.PrivateNets),\n\t\tAnonymizer:  anonymizer,\n\t\tDHCPServer:  globalContext.dhcpServer,\n\t\tEtcHosts:    hc,\n\t\tLocalDomain: config.DHCP.LocalDomainName,","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/dns.go#L84-L120","documentation":"AdGuard Home fails to initialize its DNS query log module. The querylog.New constructor validates configuration (storage paths, ignored-domain engine wiring) and returns an error when the config is invalid or the log storage cannot be created. This happens during DNS module startup, before the server starts listening.","triggerScenarios":"Calling initDNS with a querylog configuration that fails validation in querylog.New: invalid file-base path, unwritable data directory, or a malformed configuration produced after building the ignored-domains engine.","commonSituations":"Read-only or missing work/data directory, config file edited by hand with an invalid querylog section, or running AdGuard Home as a user without write permission to the data dir.","solutions":["Check that the data/work directory exists and is writable by the AdGuard Home process user","Inspect the full wrapped error (%w) — the underlying querylog error names the exact invalid field","Validate or regenerate the querylog section of the YAML config","Re-run with a clean data directory to rule out corrupted querylog storage"],"exampleFix":"# before\nglobalContext.queryLog, err = querylog.New(conf)\n# after\nglobalContext.queryLog, err = querylog.New(conf)\nif err != nil {\n    return fmt.Errorf(\"init querylog: %w\", err)\n}\n// ensure conf.FileBase points to a writable directory, e.g. /opt/AdGuardHome/data/querylog.json","handlingStrategy":"validation","validationCode":"// Go: pre-validate querylog config before initDNS\nif conf.FileBase != \"\" {\n    if err := os.MkdirAll(filepath.Dir(conf.FileBase), 0o755); err != nil {\n        return fmt.Errorf(\"querylog dir: %w\", err)\n    }\n    if f, err := os.OpenFile(conf.FileBase, os.O_CREATE|os.O_WRONLY, 0o644); err != nil {\n        return fmt.Errorf(\"querylog file unwritable: %w\", err)\n    } else { f.Close() }\n}","typeGuard":null,"tryCatchPattern":"// at startup wrapper\nif err := initDNS(ctx, params); err != nil {\n    if strings.Contains(err.Error(), \"init querylog\") {\n        log.Error(\"querylog init failed; check data dir permissions\", slogutil.KeyError, err)\n    }\n    return err\n}","preventionTips":["Run AdGuard Home under a dedicated user with write access to its data directory","Mount the data dir on writable persistent storage in containers","Validate config.yaml with the AdGuard Home config check before deploying"],"tags":["dns","adguard-home","querylog","startup","configuration"],"backgroundTag":"config-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}