{"record":{"id":"2ba6077c35e19ffc","repo":"cloudflare/cloudflared","slug":"rest-request-failed","errorCode":null,"errorMessage":"REST request failed","messagePattern":"REST request failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/base_client.go","lineNumber":169,"sourceCode":"\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)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tvar parsedRspBody []*T\n\t\treturn envelope, parsedRspBody, parseResponseBody(envelope, &parsedRspBody)\n\t}\n\treturn nil, nil, errors.New(fmt.Sprintf(\"Failed to fetch page. Server returned: %d\", pageResp.StatusCode))\n}\n\ntype response struct {\n\tSuccess    bool            `json:\"success,omitempty\"`\n\tErrors     []apiError      `json:\"errors,omitempty\"`\n\tMessages   []string        `json:\"messages,omitempty\"`\n\tResult     json.RawMessage `json:\"result,omitempty\"`","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/base_client.go#L151-L187","documentation":"Generic wrapper error in cfapi fetchPage: the HTTP request for one page of a paginated Tunnelstore listing (routes, vnets, etc.) failed at the transport level (network error, TLS failure, connection refused). fetchExhaustively stops pagination and surfaces this wrapped error for the page number involved.","triggerScenarios":"Thrown at cfapi/base_client.go:169 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity to the Cloudflare API endpoint.","Inspect the wrapped cause for timeouts vs DNS vs TLS problems and retry transient ones.","Verify proxy/firewall settings if the API is reachable from a browser."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}