waku-org / nwaku

Waku node and protocol.
Other
201 stars 53 forks source link

bug: store v3 returns error "waku message hash parsing error: Incorrect base64 string" for some cursors #2715

Closed fbarbu15 closed 5 months ago

fbarbu15 commented 5 months ago

Problem

Some cursors are returning this error, while some are working fine. It looks like a 50% of the cursors are affected

To reproduce

If you can reproduce the behavior, steps to reproduce:

  1. Have 4 messages in the store
  2. Send a store v3 request with page size 2. Ex response: {"requestId":"","statusCode":200,"statusDesc":"OK","messages":[{"messageHash":{"data":"Y/RQpwaGT4M5avLAo6n2zDbPBHD0fUwjf2vUHYjp0qs="}},{"messageHash":{"data":"oKge3KvFaY2GV5FVvtDY+rKxFR+u+0UnlZ+emeQqhkc="}}],"paginationCursor":{"data":"oKge3KvFaY2GV5FVvtDY+rKxFR+u+0UnlZ+emeQqhkc="}}
  3. Retrieve the paginationCursor from the response and use it in a new request. Ex request: curl -v -X GET "http://127.0.0.1:48915/store/v3/messages?cursor=oKge3KvFaY2GV5FVvtDY%2BrKxFR%2Bu%2B0UnlZ%2BemeQqhkc%3D&pageSize=100&ascending=true&pubsubTopic=%2Fwaku%2F2%2Frs%2F0%2F0" -H "Content-Type: application/json"

Actual behavior

In 50% of the cases I get 400 Bad Request with waku message hash parsing error: Incorrect base64 string

Expected behavior

Should work

nwaku version/commit hash

harbor.status.im/wakuorg/nwaku:latest

Additional context

Cursors that work:

RFyVEr6pcroAemrPVk0Ouj4Q6wBobcVWDeaDHPmBc3M=
yDV4lrZUseGuJT47on8FCIyAD2mLwQYBBwsO/oQPmN0=

Cursors that doesn't work:

oKge3KvFaY2GV5FVvtDY+rKxFR+u+0UnlZ+emeQqhkc=
hrMOn3lyWbX81zl/wuDZx6YkZ09HFdO8+c3xl5Y7Bv0=

Logs:

node.log

chair28980 commented 5 months ago

https://base64.guru/standards/base64url

chair28980 commented 5 months ago

Likely related: https://github.com/waku-org/nwaku/issues/2653

SionoiS commented 5 months ago

Looks like we use base64url in some places and standard base64 in others :confused:

SionoiS commented 5 months ago

fixed by https://github.com/waku-org/nwaku/pull/2718