Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (query) [#23883](https://github.com/cosmos/cosmos-sdk/pull/23883) Fix NPE in query pagination.
* (client) [#23860](https://github.com/cosmos/cosmos-sdk/pull/23860) Add missing `unordered` field for legacy amino signing of tx body.
* (x/bank) [#23836](https://github.com/cosmos/cosmos-sdk/pull/23836) Fix `DenomMetadata` rpc allow value with slashes.
* (query) [87d3a43](https://github.com/cosmos/cosmos-sdk/commit/87d3a432af95f4cf96aa02351ed5fcc51cca6e7b) Fix collection filtered pagination.
Expand Down
2 changes: 1 addition & 1 deletion types/query/collections_pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func CollectionFilteredPaginate[K, V any, C Collection[K, V], T any](
return results, new(PageResponse), nil
}
// strip the prefix from next key
if len(pageRes.NextKey) != 0 && prefix != nil {
if pageRes != nil && len(pageRes.NextKey) != 0 && prefix != nil {
pageRes.NextKey = pageRes.NextKey[len(prefix):]
}
return results, pageRes, err
Expand Down
14 changes: 14 additions & 0 deletions types/query/collections_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package query

import (
"context"
"errors"
"testing"

db "github.com/cosmos/cosmos-db"
Expand All @@ -15,6 +16,7 @@ func TestCollectionPagination(t *testing.T) {
sk, ctx := deps()
sb := collections.NewSchemaBuilder(sk)
m := collections.NewMap(sb, collections.NewPrefix(0), "_", collections.Uint64Key, collections.Uint64Value)
dummyErr := errors.New("dummy error")

for i := uint64(0); i < 300; i++ {
require.NoError(t, m.Set(ctx, i, i))
Expand Down Expand Up @@ -152,6 +154,18 @@ func TestCollectionPagination(t *testing.T) {
{Key: 295, Value: 295},
},
},
"filtered no key with error": {
req: &PageRequest{
Limit: 3,
},
expResp: &PageResponse{
NextKey: encodeKey(5),
},
filter: func(key, value uint64) (bool, error) {
return false, dummyErr
},
wantErr: dummyErr,
},
}

for name, tc := range tcs {
Expand Down