waku-org / nwaku

Waku node and protocol.
Other
183 stars 46 forks source link

bug: Deserialization error on POST `/relay/v1/auto/messages` with `ephemeral` field in body #2643

Open erhant opened 2 weeks ago

erhant commented 2 weeks ago

Problem

When ephemeral field is within the body of the POST request to /relay/v1/auto/messages field, the REST API can't deserialize the body.

Impact

Mid

To reproduce

curl -X POST "http://127.0.0.1:8645/relay/v1/auto/messages" \
 -H "content-type: application/json" \
 -d '{"payload":"ZXhhbXBsZQ==","contentTopic":"/test/0/ephemeral/proto","version":0,"timestamp":1714373499732887000}'
# OK
curl -X POST "http://127.0.0.1:8645/relay/v1/auto/messages" \
 -H "content-type: application/json" \
 -d '{"payload":"ZXhhbXBsZQ==","contentTopic":"/test/0/ephemeral/proto","version":0,"timestamp":1714373499732887000,"ephemeral":false}'
# Invalid content body, could not decode. Unable to deserialize data

Expected behavior

Should be able to deserialize as per the REST API documentation at https://waku-org.github.io/waku-rest-api/#post-/relay/v1/auto/messages

Screenshots/logs

Here is the log from failing request:

2024-04-29 10:06:23 DBG 2024-04-29 07:06:23.357+00:00 Serving API request                        tid=1 file=serverprivate.nim:202 peer=172.18.0.1:65108 meth=POST uri=/relay/v1/auto/messages path_params=[] query_params=[] content_body="(application/json, 129 bytes)"
2024-04-29 10:06:23 DBG 2024-04-29 07:06:23.358+00:00 JSON field not recognized by the current version of nwaku. Consider upgrading tid=1 file=types.nim:102 fieldName=ephemeral typeName=None
2024-04-29 10:06:23 DBG 2024-04-29 07:06:23.360+00:00 Received error response from handler       tid=1 file=serverprivate.nim:314 status=400 meth=POST peer=172.18.0.1:65108 uri=/relay/v1/auto/messages error_status="400 Bad Request" error_content_type=text/plain error_message="Invalid content body, could not decode. Unable to deserialize data"

nwaku version/commit hash

Docker image from http://harbor.status.im/wakuorg/nwaku:v0.26.0

Additional context

None