Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/server/datastore/sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ func buildListAttestedNodesQueryCTE(req *datastore.ListAttestedNodesRequest, dbT

// Filter by pagination token
if req.Pagination != nil && req.Pagination.Token != "" {
token, err := strconv.ParseUint(req.Pagination.Token, 10, 32)
token, err := strconv.ParseUint(req.Pagination.Token, 10, 64)
if err != nil {
return "", nil, status.Errorf(codes.InvalidArgument, "could not parse token '%v'", req.Pagination.Token)
}
Expand Down Expand Up @@ -2275,7 +2275,7 @@ FROM attested_node_entries N

// Filter by pagination token
if req.Pagination != nil && req.Pagination.Token != "" {
token, err := strconv.ParseUint(req.Pagination.Token, 10, 32)
token, err := strconv.ParseUint(req.Pagination.Token, 10, 64)
if err != nil {
return status.Errorf(codes.InvalidArgument, "could not parse token '%v'", req.Pagination.Token)
}
Expand Down Expand Up @@ -3819,7 +3819,7 @@ func appendListRegistrationEntriesFilterQuery(filterExp string, builder *strings
}

if len(req.Pagination.Token) > 0 {
token, err := strconv.ParseUint(req.Pagination.Token, 10, 32)
token, err := strconv.ParseUint(req.Pagination.Token, 10, 64)
if err != nil {
return false, nil, status.Errorf(codes.InvalidArgument, "could not parse token '%v'", req.Pagination.Token)
}
Expand Down Expand Up @@ -4083,7 +4083,7 @@ func applyPagination(p *datastore.Pagination, entryTx *gorm.DB) (*gorm.DB, error
entryTx = entryTx.Order("id asc").Limit(p.PageSize)

if len(p.Token) > 0 {
id, err := strconv.ParseUint(p.Token, 10, 32)
id, err := strconv.ParseUint(p.Token, 10, 64)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "could not parse token '%v'", p.Token)
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/server/datastore/sqltest/datastore_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,20 @@ func (s *Suite) TestListBundlesWithPagination() {
PageSize: 2,
},
},
{
// Regression test: tokens beyond 32 bits must parse successfully,
// since the underlying ID column is not limited to 32 bits.
name: "token larger than 32 bits",
expectedList: []*common.Bundle{},
pagination: &datastore.Pagination{
Token: "5000000000",
PageSize: 2,
},
expectedPagination: &datastore.Pagination{
Token: "",
PageSize: 2,
},
},
}
for _, test := range tests {
s.T().Run(test.name, func(t *testing.T) {
Expand Down
Loading