Skip to content

Commit d455f6e

Browse files
authored
fix: rename total to count in AIBridgeListInterceptionsResponse (coder#20410)
Thanks to the great work in coder#20393, we’ve successfully introduced offset-based pagination for this endpoint. However, the frontend expects a `count` field in the response rather than `total`. This PR updates the response payload to rename the returned key to `count` for consistency with frontend expectations and existing API patterns. This is necessary to unblock the work in coder#20331
1 parent 4bd7c7b commit d455f6e

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

coderd/apidoc/docs.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/aibridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type AIBridgeToolUsage struct {
5656
}
5757

5858
type AIBridgeListInterceptionsResponse struct {
59-
Total int64 `json:"total"`
59+
Count int64 `json:"count"`
6060
Results []AIBridgeInterception `json:"results"`
6161
}
6262

docs/reference/api/aibridge.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/schemas.md

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/aibridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (api *API) aiBridgeListInterceptions(rw http.ResponseWriter, r *http.Reques
127127
}
128128

129129
httpapi.Write(ctx, rw, http.StatusOK, codersdk.AIBridgeListInterceptionsResponse{
130-
Total: count,
130+
Count: count,
131131
Results: items,
132132
})
133133
}

enterprise/coderd/aibridge_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
269269
if len(res.Results) == 0 {
270270
break
271271
}
272-
require.EqualValues(t, len(allInterceptionIDs), res.Total)
272+
require.EqualValues(t, len(allInterceptionIDs), res.Count)
273273
require.Len(t, res.Results, 1)
274274
interceptionIDs = append(interceptionIDs, res.Results[0].ID)
275275
}
@@ -322,15 +322,15 @@ func TestAIBridgeListInterceptions(t *testing.T) {
322322
// Admin can see all interceptions.
323323
res, err := adminExperimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
324324
require.NoError(t, err)
325-
require.EqualValues(t, 2, res.Total)
325+
require.EqualValues(t, 2, res.Count)
326326
require.Len(t, res.Results, 2)
327327
require.Equal(t, i1.ID, res.Results[0].ID)
328328
require.Equal(t, i2.ID, res.Results[1].ID)
329329

330330
// Second user can only see their own interceptions.
331331
res, err = secondUserExperimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
332332
require.NoError(t, err)
333-
require.EqualValues(t, 1, res.Total)
333+
require.EqualValues(t, 1, res.Count)
334334
require.Len(t, res.Results, 1)
335335
require.Equal(t, i2.ID, res.Results[0].ID)
336336
})
@@ -501,7 +501,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
501501
ctx := testutil.Context(t, testutil.WaitLong)
502502
res, err := experimentalClient.AIBridgeListInterceptions(ctx, tc.filter)
503503
require.NoError(t, err)
504-
require.EqualValues(t, len(tc.want), res.Total)
504+
require.EqualValues(t, len(tc.want), res.Count)
505505
// We just compare UUID strings for the sake of this test.
506506
wantIDs := make([]string, len(tc.want))
507507
for i, r := range tc.want {

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)