{"record":{"id":"01d0335a49c58614","repo":"gastownhall/beads","slug":"pagination-limit-exceeded-stopped-after-d-pages-01d033","errorCode":null,"errorMessage":"pagination limit exceeded: stopped after %d pages","messagePattern":"pagination limit exceeded: stopped after (.+?) pages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/linear/client.go","lineNumber":488,"sourceCode":"\tcase \"closed\":\n\t\tfilter[\"state\"] = map[string]interface{}{\n\t\t\t\"type\": map[string]interface{}{\n\t\t\t\t\"in\": []string{\"completed\", \"canceled\"},\n\t\t\t},\n\t\t}\n\t}\n\n\tpage := 0\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn allIssues, ctx.Err()\n\t\tdefault:\n\t\t}\n\n\t\tpage++\n\t\tif page > MaxPages {\n\t\t\treturn nil, fmt.Errorf(\"pagination limit exceeded: stopped after %d pages\", MaxPages)\n\t\t}\n\n\t\tvariables := map[string]interface{}{\n\t\t\t\"filter\": filter,\n\t\t\t\"first\":  MaxPageSize,\n\t\t}\n\t\tif cursor != \"\" {\n\t\t\tvariables[\"after\"] = cursor\n\t\t}\n\n\t\treq := &GraphQLRequest{\n\t\t\tQuery:     issuesQuery,\n\t\t\tVariables: variables,\n\t\t}\n\n\t\tdata, err := c.Execute(ctx, req)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to fetch issues: %w\", err)","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/linear/client.go#L470-L506","documentation":"FetchIssues pages through Linear issues cursor-style and hard-stops after MaxPages pages to prevent unbounded loops, returning this error and discarding all accumulated issues. It means the result set (paginated at MaxPageSize per page) exceeded the maximum page budget.","triggerScenarios":"Calling FetchIssues(ctx, state) where the number of issues matching the filter (team, optional project, optional open/closed state) exceeds MaxPages × MaxPageSize — e.g. a team with thousands of open issues fetched with state=\"open\" or \"all\".","commonSituations":"Large teams with heavy issue history running a full (non-incremental) sync; a project ID filter that no longer narrows results; state=\"all\" pulls on backlogged teams.","solutions":["Use FetchIssuesSince with the last sync timestamp instead of a full FetchIssues scan","Narrow the query by setting Client.ProjectID or a tighter state filter","Raise MaxPages (and possibly MaxPageSize) constants if the budget is genuinely too small","Split the sync by project or by time window so each run stays under the page budget"],"exampleFix":"// before: full scan every run\nissues, err := client.FetchIssues(ctx, \"all\")\n// after: incremental sync\nclient := linear.NewClient(token, teamID, \"\")\nissues, err := client.FetchIssuesSince(ctx, \"all\", lastSyncTime)","handlingStrategy":"fallback","validationCode":"// Estimate the result size before a full fetch\nrecent, err := client.FetchIssuesSince(ctx, state, time.Now().Add(-24*time.Hour))\nif err != nil && strings.Contains(err.Error(), \"pagination limit exceeded\") {\n    return errors.New(\"dataset too large for a single FetchIssues run; use incremental sync\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer FetchIssuesSince with a persisted watermark over full scans","Set Client.ProjectID to narrow the result set","Raise MaxPages deliberately if the team genuinely has more data","Chunk initial backfill by time windows or by project","Alert when the page budget is hit so syncs don't silently drop data"],"tags":["pagination","linear","sync","limits"],"backgroundTag":"pagination-limit-exceeded","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}