Skip to content

feat: accept include_related query param on get workspace by ID - #29233

Open
spikecurtis wants to merge 2 commits into
mainfrom
spikecurtis/workspace-include-related
Open

spikecurtis wants to merge 2 commits into
mainfrom
spikecurtis/workspace-include-related

Conversation

@spikecurtis

@spikecurtis spikecurtis commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Part of the lite codersdk.Workspace work (GRU-82, RFC). Follows #28639, which added the wsrelated package and parser.

Wires the include_related query parameter into GET /api/v2/workspaces/{workspace}, the first endpoint to accept it. When present, the value is parsed with wsrelated.Parse and the resulting selection is threaded into workspaceData, so only the requested related data is queried. Omitting the parameter is backward compatible and returns everything (wsrelated.All). An invalid value returns 400.

Because related data can now be omitted, the handler no longer assumes the build and template are present: it uses zero values when they are absent, and only enforces the template read-authorization check (403) when the template was actually requested.

Partial-build conversion

convertWorkspaceBuilds now tolerates a build whose provisioner job or template version was deliberately omitted from the selection, so selections such as latest_build (build only) or latest_build.resources.* (resources without the job) convert correctly instead of erroring. The omitted fields are left zero (empty Job, empty TemplateVersionName). Resources are keyed by the build's JobID rather than the fetched job row, so they load independently of whether the job is selected. The integrity error is preserved for full-data callers: when a job or template version is requested but missing, conversion still fails. The selection config (wsrelated.LatestBuild) is threaded into convertWorkspaceBuilds to distinguish "not requested" from "missing".

Only this endpoint is wired; the other endpoints that produce codersdk.Workspace objects, and the codersdk client functions, come in later PRs.


Generated by Coder Agents on behalf of @spikecurtis.

@spikecurtis
spikecurtis requested a review from cstyan September 11, 2026 13:19
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

Check 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.

@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-include-related branch 3 times, most recently from 2655f42 to d675226 Compare September 14, 2026 11:45
@spikecurtis
spikecurtis marked this pull request as ready for review September 14, 2026 12:01
@spikecurtis
spikecurtis added this pull request to stack #29285 September 14, 2026 12:29
@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-include-related branch from d675226 to e506c30 Compare September 14, 2026 14:13
@spikecurtis
spikecurtis force-pushed the spikecurtis/workspace-include-related branch from e506c30 to 9067d82 Compare September 14, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants