Skip to content

Commit a166d57

Browse files
committed
fix GetLatestWorkspaceBuildsByWorkspaceIDs which was causing TestOffsetLimit to break
1 parent 8d3f253 commit a166d57

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

coderd/authzquery/workspace.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ func (q *AuthzQuerier) GetLatestWorkspaceBuildsByWorkspaceIDs(ctx context.Contex
4040
// This is not ideal as not all builds will be returned if the workspace cannot be read.
4141
// This should probably be handled differently? Maybe join workspace builds with workspace
4242
// ownership properties and filter on that.
43-
workspaces, err := q.GetWorkspaces(ctx, database.GetWorkspacesParams{WorkspaceIds: ids})
44-
if err != nil {
45-
return nil, err
46-
}
47-
48-
allowedIDs := make([]uuid.UUID, 0, len(workspaces))
49-
for _, workspace := range workspaces {
50-
allowedIDs = append(allowedIDs, workspace.ID)
43+
for _, id := range ids {
44+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceWorkspace.WithID(id)); err != nil {
45+
return nil, err
46+
}
5147
}
5248

53-
return q.database.GetLatestWorkspaceBuildsByWorkspaceIDs(ctx, allowedIDs)
49+
return q.database.GetLatestWorkspaceBuildsByWorkspaceIDs(ctx, ids)
5450
}
5551

5652
func (q *AuthzQuerier) GetWorkspaceAgentByID(ctx context.Context, id uuid.UUID) (database.WorkspaceAgent, error) {

0 commit comments

Comments
 (0)