{"record":{"id":"57beff2f6f89009c","repo":"cloudflare/cloudflared","slug":"error-parsing-page-d","errorCode":null,"errorMessage":"Error Parsing page %d","messagePattern":"Error Parsing page (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/base_client.go","lineNumber":155,"sourceCode":"func parseResponseBody(result *response, data interface{}) error {\n\t// At this point we know the API call succeeded, so, parse out the inner\n\t// result into the datatype provided as a parameter.\n\tif err := json.Unmarshal(result.Result, &data); err != nil {\n\t\treturn errors.Wrap(err, \"the Cloudflare API response was an unexpected type\")\n\t}\n\treturn nil\n}\n\nfunc fetchExhaustively[T any](requestFn func(int) (*http.Response, error)) ([]*T, error) {\n\tpage := 0\n\tvar fullResponse []*T\n\n\tfor {\n\t\tpage += 1\n\t\tenvelope, parsedBody, err := fetchPage[T](requestFn, page)\n\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, fmt.Sprintf(\"Error Parsing page %d\", page))\n\t\t}\n\n\t\tfullResponse = append(fullResponse, parsedBody...)\n\t\tif envelope.Pagination.Count < envelope.Pagination.PerPage || len(fullResponse) >= envelope.Pagination.TotalCount {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn fullResponse, nil\n}\n\nfunc fetchPage[T any](requestFn func(int) (*http.Response, error), page int) (*response, []*T, error) {\n\tpageResp, err := requestFn(page)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"REST request failed\")\n\t}\n\tdefer pageResp.Body.Close()\n\tif pageResp.StatusCode == http.StatusOK {\n\t\tenvelope, err := parseResponseEnvelope(pageResp.Body)","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/base_client.go#L137-L173","documentation":"fetchExhaustively paginates through list endpoints page by page; if fetchPage fails for any page it wraps the error with 'Error Parsing page %d'. Any per-page failure (HTTP error, decode failure, unexpected shape) is surfaced with the page number to identify which page broke.","triggerScenarios":"A specific page of a paginated list (routes, virtual networks) fails: transient HTTP error mid-pagination, rate limiting on later pages, or malformed data on one page.","commonSituations":"Large accounts with many teamnet routes where later pages hit rate limits or timeouts; network instability during long multi-page fetches.","solutions":["Look at the wrapped inner error to see whether it's an HTTP failure or a decode failure for that page.","Retry the operation — transient failures mid-pagination are common.","If rate limited, back off and retry with fewer concurrent API calls.","Upgrade the library if the inner error indicates an unexpected response shape."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"routes, err := client.ListRoutes(t, filter)\nif err != nil {\n\tvar perr *pageParseError // inspect wrapped 'Error Parsing page N'\n\tif strings.Contains(err.Error(), \"Error Parsing page\") {\n\t\terr = retry(3, backoff, func() error {\n\t\tvar e error\n\t\troutes, e = client.ListRoutes(t, filter)\n\t\treturn e\n\t\t})\n\t}\n\tif err != nil { return err }\n}","preventionTips":["Add retry/backoff around paginated list calls.","Avoid concurrent bulk API calls that trigger rate limits mid-pagination.","Handle large accounts by ensuring generous HTTP timeouts."],"tags":["go","pagination","api-client","http"],"backgroundTag":"api-request-failed","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}