Skip to content

Commit

Permalink
fix: pagination enforce range
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Van Ootegem <[email protected]>
  • Loading branch information
EVODelavega committed Oct 16, 2023
1 parent a32e296 commit 63d6ba0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
- [9751](https://github.com/vegaprotocol/vega/issues/9751) - Make sure that LP fee party accounts exists.
- [9762](https://github.com/vegaprotocol/vega/issues/9762) - Referral fees API not filtering by party correctly.
- [9775](https://github.com/vegaprotocol/vega/issues/9775) - Do not pay discount if set is not eligible
- [9408](https://github.com/vegaprotocol/vega/issues/9408) - Enforce pagination range.

## 0.72.1

Expand Down
8 changes: 4 additions & 4 deletions datanode/entities/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func CursorPaginationFromProto(cp *v2.Pagination) (CursorPagination, error) {
}

if cp.First != nil {
if *cp.First < 0 {
if *cp.First < 0 || *cp.First > defaultPageSize {
return CursorPagination{}, ErrCursorOverflow
}
forwardOffset = &offset{
Expand All @@ -135,7 +135,7 @@ func CursorPaginationFromProto(cp *v2.Pagination) (CursorPagination, error) {
forwardOffset.Cursor = &after
}
} else if cp.Last != nil {
if *cp.Last < 0 {
if *cp.Last < 0 || *cp.Last > defaultPageSize {
return CursorPagination{}, ErrCursorOverflow
}
backwardOffset = &offset{
Expand Down Expand Up @@ -228,8 +228,8 @@ func validatePagination(pagination CursorPagination) error {
}

limit := *cursorOffset.Limit
if limit <= 0 {
return errors.New("pagination limit must be greater than 0")
if limit <= 0 || limit > defaultPageSize {
return errors.Errorf("pagination limit must be in range 0-%d", defaultPageSize)
}

return nil
Expand Down

0 comments on commit 63d6ba0

Please sign in to comment.