fix: Adjust pagination limit to be zero-based (#2663)

There isn't a use-case for querying a limit of zero. Using
-1 led to issues when using default parameters for querying.
This commit is contained in:
Kyle Carberry
2022-06-26 15:23:25 -05:00
committed by GitHub
parent 95e854d144
commit 01c31b47a3
7 changed files with 14 additions and 16 deletions

View File

@ -17,7 +17,7 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
params := codersdk.Pagination{
AfterID: parser.UUID(queryParams, uuid.Nil, "after_id"),
// Limit default to "-1" which returns all results
Limit: parser.Int(queryParams, -1, "limit"),
Limit: parser.Int(queryParams, 0, "limit"),
Offset: parser.Int(queryParams, 0, "offset"),
}
if len(parser.Errors) > 0 {