{"record":{"id":"e1939f5b2e77e26e","repo":"jeessy2/ddns-go","slug":"paginated-query-failed-at-page-d-w","errorCode":null,"errorMessage":"paginated query failed at page %d: %w","messagePattern":"paginated query failed at page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/hipmdnsmgr.go","lineNumber":286,"sourceCode":"\t}\n\n\t// Check if exact match is found\n\tfor _, d := range domains {\n\t\tif d.Name == domainName {\n\t\t\treturn d.ID, nil\n\t\t}\n\t}\n\n\t// Method 2: If keyword query not found, use list matching as fallback (compatible with old API)\n\t// Paginate through all domains to find the target\n\tconst pageSize = 100\n\tcurrentPage := 1\n\n\tfor {\n\t\tpath := fmt.Sprintf(\"/domains?page=%d&pageSize=%d\", currentPage, pageSize)\n\t\tapiResp, err := h.request(baseURL, apiToken, \"GET\", path, nil)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"paginated query failed at page %d: %w\", currentPage, err)\n\t\t}\n\n\t\tif apiResp.Code != 0 {\n\t\t\treturn 0, fmt.Errorf(\"paginated query API error at page %d: %s\", currentPage, apiResp.Msg)\n\t\t}\n\n\t\t// Parse response with smart format detection\n\t\tvar pageDomains []DnsMgrDomain\n\t\tvar total int\n\n\t\tvar rawData interface{}\n\t\tif err := json.Unmarshal(apiResp.Data, &rawData); err == nil {\n\t\t\tswitch v := rawData.(type) {\n\t\t\tcase []interface{}:\n\t\t\t\tjsonData, _ := json.Marshal(v)\n\t\t\t\tjson.Unmarshal(jsonData, &pageDomains)\n\t\t\tcase map[string]interface{}:\n\t\t\t\tif listData, ok := v[\"list\"]; ok {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/hipmdnsmgr.go#L268-L304","documentation":"After the keyword query finds no exact match, getDomainID falls back to paginating /domains?page=N&pageSize=100. If any page request fails at the HTTP/transport level (h.request returns error), this wrapped error reports which page failed. It is not raised for API-level (code!=0) errors — those produce 'paginated query API error'.","triggerScenarios":"Transport failure during the fallback pagination loop: DNS timeout, connection refused/reset, TLS error, or proxy failure while fetching page N of /domains.","commonSituations":"Large number of domains forcing multi-page fallback walks that hit a flaky network or rate-limit-induced connection drop; self-hosted DNSMgr restarted mid-run; slow endpoint exceeding the http.Client timeout.","solutions":["Check network connectivity/proxy settings between ddns-go and the DNSMgr host","Increase the HTTP client timeout in config if the endpoint is slow","Most importantly: ensure the configured domain matches exactly so the efficient keyword query (method 1) succeeds and pagination never runs","Reduce domain count on the DNSMgr server or verify server stability/restart behavior","Retry the DDNS run — transient network errors typically resolve on the next cycle"],"exampleFix":"// before (config domain mismatch triggers pagination fallback)\nDomain: \"sub.example.org\"   # registered in DNSMgr as example.org only\n// after\nDomain: \"sub.example.org\" + register example.org in DNSMgr\n// or ensure exact domain entry exists so keyword search matches and fallback pagination is skipped","handlingStrategy":"retry","validationCode":"// keep the domain registered and exactly named in DNSMgr so the fast keyword\n// query succeeds and fallback pagination never runs\nkeywordURL := base + \"/api/domains?page=1&pageSize=1&keyword=\" + url.QueryEscape(domainName)\nresp, err := http.Get(keywordURL) // with auth header\n// if this returns the domain, the paginated fallback path is skipped entirely","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"paginated query failed\") {\n    if isTransient(err) { // net.Error timeout, connection reset\n        time.Sleep(2 * time.Second)\n        retryOnce() // safe: reads only, idempotent\n    }\n    log.Printf(\"domain pagination aborted at page: %v\", err)\n}","preventionTips":["Register the exact domain in DNSMgr so keyword search matches (avoiding pagination entirely)","Increase HTTP client timeout for slow self-hosted endpoints","Keep domain count under one page (100) or ensure server uptime during DDNS cycles","Use a stable network path (no flaky proxies) between ddns-go and DNSMgr"],"tags":["go","network","api","pagination"],"backgroundTag":"paginated-request-failed","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}