-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: light push response is empty when protobuf decode fails #1641
Comments
What's the RPC command to do that? I don't see it in the RPC spec. |
Although this issue has the "rpc" word in many places and even within the nwaku/waku/waku_lightpush/protocol.nim Line 42 in 9085b1b
@fryorcraken - How can easily send different |
Yes it's RPC as
I would recommend to use nwaku as a client to reproduce/test. Here is how we set the content topic to send messages in js-waku: https://github.com/waku-org/js-waku/blob/d049ebbc3417e5c20eccba3aa1b9fc5382e8d7fc/packages/tests/tests/light_push.node.spec.ts#L22 However an empty content topic is now explicitly forbidden: https://github.com/waku-org/js-waku/blob/d049ebbc3417e5c20eccba3aa1b9fc5382e8d7fc/packages/core/src/lib/message/version_0.ts#L79C1-L79C1 |
nwaku/waku/waku_lightpush/protocol.nim Lines 42 to 45 in dac072f
The issue is here if we are failed to parse the proto we're just returning ideally we should return the response nwaku/waku/waku_lightpush/protocol.nim Lines 76 to 77 in dac072f
Extending the response and sending it back should solve the issue. |
Looking at the existing two tests for Lightpush, I don't quite understand how they work (which may be explained by my lack of Nim knowledge, I admit, but still). We have two tests: for a successful and for an erring case. What I don't understand is how the outcome of the test depends on what actually happens. In particular, for the success-case, the handler returns an OK (as it seems to me) irrespective of the actual result of the push: nwaku/tests/test_waku_lightpush.nim Line 47 in 57e511f
And then we check that the result is indeed OK: nwaku/tests/test_waku_lightpush.nim Line 66 in 57e511f
Likewise, for the fail-case test, the handler returns an error: nwaku/tests/test_waku_lightpush.nim Line 91 in 57e511f
And then we check that the result is indeed an error: nwaku/tests/test_waku_lightpush.nim Line 110 in 57e511f
For me it looks like these tests always pass by definition. What am I missing? |
Also, I have a meta-question here. Shall we distinguish between "no content topic" and "empty content topic"? For me it seems that the former is a decoding issue, while the latter is more high-level one, related to interpretation of data. Should we treat an empty content topic as a decoding error too? After all, the protobuf in this case is decoded successfully, it just so happens that one of the fields equals some special value (an empty string), which the spec forbids. If we treat an empty content topic similarly to a missing one, then I would introduce a new check here, so that we additionally check whether nwaku/waku/waku_core/message/codec.nim Lines 46 to 49 in 11e7394
Otherwise, we could check for nwaku/waku/waku_lightpush/protocol.nim Lines 56 to 57 in 11e7394
Any thoughts? |
I've stumble upon tests like that before. They don't test "end to end", in this case the best would be to actually check if the message was send via
IMO a clear separation between protocol error and in this case decode error would be best. |
Ok, I'm gonna go step by step here. In a test, how do I create a server that uses the actual handler described in the protocol, instead of a mock handler that always returns In particular, how do I bring the logic from here: nwaku/waku/waku_lightpush/protocol.nim Lines 38 to 77 in 11e7394
to here: nwaku/tests/test_waku_lightpush.nim Line 94 in 57e511f
? |
You don't have to. The handler you pass to Currently the test is very narrow, what I meant to say was that it maybe better broaden the scope. Narrow:
Broader:
Very Broad:
Hope it helps :) |
I'm not sure I understand how "wrapping" works exactly... In the test, we initialize a server passing nwaku/tests/test_waku_lightpush.nim Lines 45 to 50 in 57e511f
How does this linked to nwaku/waku/waku_lightpush/protocol.nim Line 38 in a01b63a
and L62 in particular? nwaku/waku/waku_lightpush/protocol.nim Line 62 in a01b63a
|
When nwaku/waku/waku_lightpush/protocol.nim Line 36 in a01b63a
Then nwaku/waku/waku_lightpush/protocol.nim Line 79 in a01b63a
Resulting in handler Maybe this GC magic is unfamiliar to you? I know I was a bit loss at first because of my Rust (no GC) background. |
Related: #2059 |
That's quite likely! This what I think I understand (please correct me if I'm wrong). In nwaku/waku/waku_lightpush/protocol.nim Lines 86 to 87 in a01b63a
Here, the nwaku/waku/waku_lightpush/protocol.nim Line 62 in a01b63a
Finally, we assign nwaku/waku/waku_lightpush/protocol.nim Line 79 in a01b63a
Here, I can see how
In the test, we initialize the server here: nwaku/tests/test_waku_lightpush.nim Line 50 in 57e511f
where inside nwaku/tests/test_waku_lightpush.nim Line 20 in 57e511f
And the nwaku/tests/test_waku_lightpush.nim Lines 45 to 47 in 57e511f
My confusion was caused by the fact that what is called Thank you so much @SionoiS for your time, your comments are truly helpful! |
A more high-level question: what is the expected behavior w.r.t. client-server interaction in case the client sends an invalid request? As an example, consider the case when the request can't be decoded. From what I see, on the server side, the handler will nwaku/waku/waku_lightpush/protocol.nim Lines 42 to 45 in a01b63a
On the client side, however, it seems that the client is expecting a push response for erring cases (or is it?): nwaku/waku/waku_lightpush/client.nim Lines 60 to 65 in a01b63a
How should such cases be handled generally? I mean the scenarios when a client sends a request to a server, but the request is invalid in some way, therefore no message is pushed to the Relay network. How should the server respond? Should this case be handled differently from a scenario when a server did push a message, but the push failed due to issues on the Relay side? |
Actually i just realized that I did not understand how it worked either. Because nwaku/waku/waku_lightpush/protocol.nim Line 33 in 1c4533a
and nwaku/waku/waku_lightpush/protocol.nim Line 79 in 1c4533a
The handlers call order is;
IMO always sending a response is best. We don't do that here for some reason.... Good error messages are also important. |
@s-tikhomirov from now on, you can use Rest API to test/debug lightpush. |
Problem
When js-waku client tries to use light push with a waku message that has no content topic, nwaku sends an empty response back.
Expected: an error in the light push response to point towards decoding issue.
Impact
To reproduce
If you can reproduce the behavior, steps to reproduce:
Expected behavior
rpc light push response contains an error
Screenshots/logs
nwaku_Waku_Light_Push_[node_only]_Push_successfully.log
nwaku version/commit hash
v0.16.0
The text was updated successfully, but these errors were encountered: