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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy