{"record":{"id":"922d2ea395eb6abf","repo":"Tencent/WeKnora","slug":"paginate-s-w","errorCode":null,"errorMessage":"paginate %s: %w","messagePattern":"paginate (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/datasource/connector/notion/client.go","lineNumber":457,"sourceCode":"\t\t\t\"page_size\": 100,\n\t\t}\n\t\tif startCursor != \"\" {\n\t\t\tbody[\"start_cursor\"] = startCursor\n\t\t}\n\n\t\tvar respBody []byte\n\t\tvar err error\n\t\tif method == http.MethodPost {\n\t\t\trespBody, err = c.doRequest(ctx, method, path, body)\n\t\t} else {\n\t\t\tp := path\n\t\t\tif startCursor != \"\" {\n\t\t\t\tp += \"?start_cursor=\" + startCursor + \"&page_size=100\"\n\t\t\t}\n\t\t\trespBody, err = c.doRequest(ctx, method, p, nil)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"paginate %s: %w\", path, err)\n\t\t}\n\n\t\tvar resp paginatedResponse\n\t\tif err := json.Unmarshal(respBody, &resp); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unmarshal paginated response: %w\", err)\n\t\t}\n\n\t\tvar pages []notionPage\n\t\tif err := json.Unmarshal(resp.Results, &pages); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unmarshal page results: %w\", err)\n\t\t}\n\n\t\tfor i := range pages {\n\t\t\tpages[i].Title = extractTitle(&pages[i])\n\t\t}\n\n\t\tallPages = append(allPages, pages...)\n","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/datasource/connector/notion/client.go#L439-L475","documentation":"paginatePages wraps any failure from c.doRequest during cursor-based pagination of a Notion endpoint (path included for context). Any HTTP-level or API-level error (4xx/5xx from doRequest) surfaces as \"paginate <endpoint>: <cause>\".","triggerScenarios":"doRequest returns an error while fetching a page of results from the search or database-query endpoint — invalid API key, rate limit, network error, or Notion returning an error payload.","commonSituations":"Invalid/revoked Notion integration token, Notion 429 rate-limit responses during large pagination loops, querying a database the integration has not been shared with (403).","solutions":["Read the wrapped cause to identify the HTTP status / Notion error code","Verify the integration token is valid and the database/page is shared with the integration","Back off on 429s and retry; check Notion's rate limits","Ensure the endpoint path is correct for the Notion API version"],"exampleFix":"// inspect cause\nif errors.Is(err, datasource.ErrInvalidCredentials) { ... }\nlog.Printf(\"pagination failed: %v\", err) // shows wrapped doRequest cause","handlingStrategy":"retry","validationCode":"if !strings.HasPrefix(strings.TrimSpace(apiKey), \"secret_\") { return errors.New(\"invalid Notion token format\") }","typeGuard":null,"tryCatchPattern":"pages, err := client.SearchPages(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"paginate\") && isRateLimited(err) {\n        time.Sleep(backoff); retry()\n    }\n    return err\n}","preventionTips":["Share databases/pages with the integration before querying","Respect Notion's ~3 req/s rate limit during pagination","Pin the Notion API version the connector expects"],"tags":["notion","pagination","api-error"],"backgroundTag":"api-pagination-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}