feat!: bound page size on the workspaces list endpoint - #28040
Draft
jscottmiller wants to merge 1 commit into
Draft
feat!: bound page size on the workspaces list endpoint#28040jscottmiller wants to merge 1 commit into
jscottmiller wants to merge 1 commit into
Conversation
GET /api/v2/workspaces now resolves an omitted limit to 100 and rejects limit=0 or limit>100 instead of returning every row. The shared ParsePagination and every other list endpoint are unchanged. Callers that previously relied on a single unbounded request now page to exhaustion through codersdk.Client.AllWorkspaces or API.getAllWorkspaces, which advance the offset by the requested page size and stop when the offset reaches the count the server reports. Callers that only read the total request a single row.
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /api/v2/workspacestreated an omitted or zerolimitas "no limit" and passed it to SQL asNULL. It now resolves an omittedlimitto 100 and rejectslimit=0orlimit>100with a400. Only this endpoint changes: the sharedcoderd.ParsePaginationis untouched, andParsePaginationBoundedis a second entry point used by the workspaces handler alone. Other list endpoints get bounded individually, later.Breaking: a client that omitted
limitto fetch every workspace now receives the first 100.limit=0is rejected.Callers that relied on one unbounded request now page to exhaustion through
codersdk.Client.AllWorkspacesorAPI.getAllWorkspaces; callers that only read the total request a single row. Both helpers advance the offset by the requested page size and stop when it reaches the responsecount— not on a short page. A page can be short without the set being exhausted, becauseconvertWorkspacesdrops workspaces whose latest build or template the requester cannot read afterLIMIT/OFFSETwere applied in SQL.len(page) < pageSizetruncates silently andoffset += len(page)duplicates rows; both patterns existed in the tree and are fixed here.Plan and deferred work
Server:
codersdk.WorkspacesPageLimit = 100(also generated intotypesGenerated.ts),ParsePaginationBoundedused only by the workspaces handler, swagger anddocs/reference/api/workspaces.mdregenerated. An out-of-rangelimitis rejected rather than clamped so a caller never silently receives fewer rows than it asked for.Callers routed through the paging helpers:
cli/list.go(QueryConvertWorkspaces, socoder listandcoder schedule),cli/ssh.gocompletions,cli/configssh.go, bothcli/exp_scaletest.gohelpers,scaletest/prebuilds/run.go(duplicate local helper deleted), bothcodersdk/toolsdksites, and the frontend agents pages plususeWorkspacesToBeDeleted.supportkeeps its own capped loop, now with page sizemin(cap, 100)and count-based termination. Count-only callers (UsageIndicator,TemplatePageHeader,DisableWorkspaceSharingDialog) sendlimit: 1.An omitted
limitdefaults rather than erroring because ~108client.Workspacescall sites in tests omit it; erroring would turn this into a repo-wide edit and a harsher external break for no added safety.Deliberately out of scope: bounding any other endpoint (
provisionerjobs,provisionerdaemons,exp_chats,agentfirewall,members,audit, AIBridge, template ACL),enterprise/cli/groupedit.gouser paging, the undetectable truncation in/templates/{template}/acl/available, unboundedoffsetand deep-offset cost, and cursor (AfterID) paging. Recorded with the rest of the abandoned broad-bound attempt incoder/scott-misc,notes/PLAT-386-pagination-dead-ends.md.Tests:
TestPaginationBounded, endpoint-levelTestWorkspacesPageLimit,TestAllWorkspaces, andgetAllWorkspacesvitest cases covering offset progression, short pages, empty results, and caller-supplied pagination being overridden.Created with Coder Agents on behalf of @jscottmiller.