jeessy2/ddns-go · error

paginated record query failed at page %d: %w

Error message

paginated record query failed at page %d: %w

What it means

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.

Source

Thrown at dns/hipmdnsmgr.go:351

		}
	}

	return 0, fmt.Errorf("domain %s not found", domainName)
}

// getRecord Get DNS record
// Paginate through all records to find the target
func (h *HiPMDnsMgr) getRecord(baseURL, apiToken string, domainID int, subDomain, recordType string) (*DnsMgrRecord, error) {
	const pageSize = 100
	currentPage := 1

	for {
		path := fmt.Sprintf("/domains/%d/records?page=%d&pageSize=%d&subdomain=%s&type=%s",
			domainID, currentPage, pageSize, subDomain, recordType)

		apiResp, err := h.request(baseURL, apiToken, "GET", path, nil)
		if err != nil {
			return nil, fmt.Errorf("paginated record query failed at page %d: %w", currentPage, err)
		}

		if apiResp.Code != 0 {
			return nil, fmt.Errorf("paginated record query API error at page %d: %s", currentPage, apiResp.Msg)
		}

		var recordList DnsMgrRecordList
		if err := json.Unmarshal(apiResp.Data, &recordList); err != nil {
			return nil, fmt.Errorf("failed to parse record list: %w", err)
		}

		// Find matching record in current page
		for _, r := range recordList.List {
			if r.Name == subDomain && r.Type == recordType {
				return &r, nil
			}
		}

View on GitHub (pinned to 5874c2e666)

Solutions

  1. Inspect the wrapped cause (err chain) to identify network vs HTTP failure
  2. Retry with exponential backoff; pagination failures are often transient
  3. Check connectivity/DNS to the provider API host
  4. Verify the API token is still valid if the cause is an HTTP auth failure

Example fix

// before
return nil, fmt.Errorf("paginated record query failed at page %d: %w", currentPage, err)
// after
if err != nil {
    if isRetryable(err) && currentPage <= 3 { time.Sleep(retryBackoff); continue }
    return nil, fmt.Errorf("paginated record query failed at page %d: %w", currentPage, err)
}
Defensive patterns

Strategy: retry

Validate before calling

// Go: pre-check connectivity to provider host
conn, err := net.DialTimeout("tcp", host+":443", 5*time.Second)
if err != nil { return fmt.Errorf("provider unreachable: %w", err) }
conn.Close()

Try / catch

rec, err := mgr.getRecord(baseURL, token, domainID, sub, rtype)
if err != nil {
    var netErr net.Error
    if errors.As(err, &netErr) && netErr.Timeout() {
        time.Sleep(2 * time.Second)
        rec, err = mgr.getRecord(baseURL, token, domainID, sub, rtype)
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: 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.

Common situations: Local network/VPN issues, provider throttling causing dropped connections, very long pagination exceeding timeouts, or transient provider 5xx.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03). Data as JSON: /api/errors/59917355a8d9647e. Report an issue: GitHub.