{"record":{"id":"59917355a8d9647e","repo":"jeessy2/ddns-go","slug":"paginated-record-query-failed-at-page-d-w","errorCode":null,"errorMessage":"paginated record query failed at page %d: %w","messagePattern":"paginated record query failed at page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/hipmdnsmgr.go","lineNumber":351,"sourceCode":"\t\t}\n\t}\n\n\treturn 0, fmt.Errorf(\"domain %s not found\", domainName)\n}\n\n// getRecord Get DNS record\n// Paginate through all records to find the target\nfunc (h *HiPMDnsMgr) getRecord(baseURL, apiToken string, domainID int, subDomain, recordType string) (*DnsMgrRecord, error) {\n\tconst pageSize = 100\n\tcurrentPage := 1\n\n\tfor {\n\t\tpath := fmt.Sprintf(\"/domains/%d/records?page=%d&pageSize=%d&subdomain=%s&type=%s\",\n\t\t\tdomainID, currentPage, pageSize, subDomain, recordType)\n\n\t\tapiResp, err := h.request(baseURL, apiToken, \"GET\", path, nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"paginated record query failed at page %d: %w\", currentPage, err)\n\t\t}\n\n\t\tif apiResp.Code != 0 {\n\t\t\treturn nil, fmt.Errorf(\"paginated record query API error at page %d: %s\", currentPage, apiResp.Msg)\n\t\t}\n\n\t\tvar recordList DnsMgrRecordList\n\t\tif err := json.Unmarshal(apiResp.Data, &recordList); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse record list: %w\", err)\n\t\t}\n\n\t\t// Find matching record in current page\n\t\tfor _, r := range recordList.List {\n\t\t\tif r.Name == subDomain && r.Type == recordType {\n\t\t\t\treturn &r, nil\n\t\t\t}\n\t\t}\n","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/hipmdnsmgr.go#L333-L369","documentation":"getRecord paginates GET /domains/{id}/records; when h.request fails at the transport level (network error, non-2xx HTTP, timeout) on any page, the failure is wrapped with the page number and returned to updateRecord. This means the record lookup never completed, not that the record is absent.","triggerScenarios":"h.request returns err while fetching a records page — DNS resolution failure, connection refused/reset, TLS error, HTTP timeout, or 5xx/4xx from the provider during the paged record scan.","commonSituations":"Local network/VPN issues, provider throttling causing dropped connections, very long pagination exceeding timeouts, or transient provider 5xx.","solutions":["Inspect the wrapped cause (err chain) to identify network vs HTTP failure","Retry with exponential backoff; pagination failures are often transient","Check connectivity/DNS to the provider API host","Verify the API token is still valid if the cause is an HTTP auth failure"],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"paginated record query failed at page %d: %w\", currentPage, err)\n// after\nif err != nil {\n    if isRetryable(err) && currentPage <= 3 { time.Sleep(retryBackoff); continue }\n    return nil, fmt.Errorf(\"paginated record query failed at page %d: %w\", currentPage, err)\n}","handlingStrategy":"retry","validationCode":"// Go: pre-check connectivity to provider host\nconn, err := net.DialTimeout(\"tcp\", host+\":443\", 5*time.Second)\nif err != nil { return fmt.Errorf(\"provider unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"rec, err := mgr.getRecord(baseURL, token, domainID, sub, rtype)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        time.Sleep(2 * time.Second)\n        rec, err = mgr.getRecord(baseURL, token, domainID, sub, rtype)\n    }\n    if err != nil { return err }\n}","preventionTips":["Set a generous but bounded HTTP client timeout","Use exponential backoff for transient network failures","Monitor network path to the provider API host","Avoid rescanning all pages on every update; cache domain/record IDs"],"tags":["dns","network","http","pagination"],"backgroundTag":"http-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"}