Skip to content

Commit 6b3f865

Browse files
committed
add comment to protect 0 as limit
1 parent 18f6bbf commit 6b3f865

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

coderd/pagination.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
1717
parser := httpapi.NewQueryParamParser()
1818
params := codersdk.Pagination{
1919
AfterID: parser.UUID(queryParams, uuid.Nil, "after_id"),
20-
Limit: int(parser.PositiveInt32(queryParams, 0, "limit")),
21-
Offset: int(parser.PositiveInt32(queryParams, 0, "offset")),
20+
// A limit of 0 should be interpreted by the SQL query as "null" or
21+
// "no limit". Do not make this value anything besides 0.
22+
Limit: int(parser.PositiveInt32(queryParams, 0, "limit")),
23+
Offset: int(parser.PositiveInt32(queryParams, 0, "offset")),
2224
}
2325
if len(parser.Errors) > 0 {
2426
httpapi.Write(ctx, w, http.StatusBadRequest, codersdk.Response{

0 commit comments

Comments
 (0)