{"record":{"id":"7ba3e7d71d32ae5c","repo":"AdguardTeam/AdGuardHome","slug":"networksetup-failed-to-set-dns-servers-w","errorCode":null,"errorMessage":"networksetup failed to set dns servers: %w","messagePattern":"networksetup failed to set dns servers: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghnet/net_darwin.go","lineNumber":165,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\tif portInfo.static {\n\t\treturn errors.Error(\"ip address is already static\")\n\t}\n\n\tdnsAddrs, err := getEtcResolvConfServers()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\targs := append([]string{\"-setdnsservers\", portInfo.name}, dnsAddrs...)\n\n\t// Setting DNS servers is necessary when configuring a static IP.\n\terr = executil.RunWithPeek(ctx, cmdCons, aghos.MaxCmdOutputSize, networkSetupCmd, args...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"networksetup failed to set dns servers: %w\", err)\n\t}\n\n\t// Actually configures hardware port to have static IP.\n\terr = executil.RunWithPeek(\n\t\tctx,\n\t\tcmdCons,\n\t\taghos.MaxCmdOutputSize,\n\t\tnetworkSetupCmd,\n\t\t\"-setmanual\",\n\t\tportInfo.name,\n\t\tportInfo.ip,\n\t\tportInfo.subnet,\n\t\tportInfo.gatewayIP,\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"networksetup failed to configure dns servers: %w\", err)\n\t}\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghnet/net_darwin.go#L147-L183","documentation":"newQueryLog validates the configured rotation interval with validateIvl before returning the query log instance; an unsupported interval (wrong units, out of allowed range, or zero/negative) is wrapped as 'unsupported interval'. This fails construction, so query logging cannot start with that config.","triggerScenarios":"Creating a query log (New or in tests) with conf.RotationIvl set to a value validateIvl rejects — e.g. a negative duration, an interval smaller/larger than allowed bounds, or not a whole multiple of supported units.","commonSituations":"Setting rotation_interval in the config to 0, a negative number, or a fractional/nonstandard unit; upgrading to a version that tightened the allowed interval range; unit mismatch (seconds vs milliseconds) when programmatically generating config.","solutions":["Check validateIvl's bounds in internal/querylog/querylog.go and adjust the interval","Set rotation_interval to a supported positive duration within the allowed range (e.g. 24h or 7d in the UI)","Regenerate the config programmatically with explicit time.Duration units","Restart/recreate the query log after fixing the config"],"exampleFix":"// before\ncfg.RotationIvl = 0\n// after\ncfg.RotationIvl = 24 * time.Hour","handlingStrategy":"validation","validationCode":"if conf.RotationIvl <= 0 || conf.RotationIvl%time.Minute != 0 {\n    return fmt.Errorf(\"bad rotation interval %s\", conf.RotationIvl)\n}","typeGuard":"func isValidRotationIvl(d time.Duration) bool {\n    return d > 0 && d%time.Minute == 0\n}","tryCatchPattern":"ql, err := querylog.New(ctx, conf)\nif err != nil && strings.Contains(err.Error(), \"unsupported interval\") {\n    // default the interval and retry construction\n}","preventionTips":["Always set explicit time.Duration units","Bound-check generated config values","Unit-test config generation against validateIvl rules"],"tags":["querylog","config","validation","go"],"backgroundTag":"config-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}