-
Notifications
You must be signed in to change notification settings - Fork 175
fix: Added multiselect type consistency in negotiate method #838
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
base: main
Are you sure you want to change the base?
Conversation
…es to handle none. Added newsfragment.
Hello @unniznd ALLOWED_EXTENSIONS = {
".breaking.rst",
".bugfix.rst",
".deprecation.rst",
".docs.rst",
".feature.rst",
".internal.rst",
".misc.rst",
".performance.rst",
".removal.rst",
} |
@acul71 I have fixed it. |
Great. |
Yes, everything passes. |
@unniznd : HI Aanand. Thank you for submitting the PR. Appreciate it. Please resolve the merge conflicts. CCing @acul71 and @sumanjeet0012, who will help you arrive at a good conclusion on the issue. |
@seetadev I have resolved the conflicts. |
@unniznd : Sorry, 4 CI/CD issues still remains. No worries, take your time :) Appreciate the efforts. |
@seetadev Fixed the CI/CD issue. Can you review the PR and give some feedback? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @unniznd
Can you modify the text message something like as suggested ?
Can you add a test the validates the change (raise StreamFailure) ?
What happened to this:
https://github.com/libp2p/py-libp2p/pull/814/files/96ffba93719df1647c7c99f3cf6a6e17402f9e83#diff-123980bde25d7c36a2c507e8eda411bbff661cff3aa6c97382b465d632d888ee
libp2p/host/basic_host.py
Outdated
@@ -288,6 +288,9 @@ async def _swarm_stream_handler(self, net_stream: INetStream) -> None: | |||
protocol, handler = await self.multiselect.negotiate( | |||
MultiselectCommunicator(net_stream), self.negotiate_timeout | |||
) | |||
if protocol is None: | |||
await net_stream.reset() | |||
raise StreamFailure("No protocol selected") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For error messages, can you be more verbose, something like:
raise StreamFailure("Failed to negotiate protocol: no protocol selected")
@acul71 I have added a testcase for this. Can you review the code and give some feedback? Should I update all the error messages since other messages were done by someone else in a different PR? I closed the other PR since I unfortunately rebased the branch, and other commits made in the main branch were applied to it. So I thought to close and create a new PR that will be cleaner |
Yes please. I think to remember I've see another couple of error messages to fix. |
Thanks @unniznd the PR is well done. |
@seetadev @pacrob Quick OverviewFixed type consistency in Key Changes
Impact
Files Changed
Recommendation✅ APPROVE - Clean, safe, well-tested fix that improves type consistency. |
@@ -118,6 +118,8 @@ async def select_transport( | |||
# Select protocol if non-initiator | |||
protocol, _ = await self.multiselect.negotiate(communicator) | |||
if protocol is None: | |||
raise MultiselectError("fail to negotiate a security protocol") | |||
raise MultiselectError( | |||
"fail to negotiate a security protocol: no protocl selected" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fail to negotiate a security protocol: no protocl selected" | |
"Failed to negotiate a security protocol: no protocol selected" |
@@ -85,7 +85,9 @@ async def select_transport(self, conn: IRawConnection) -> TMuxerClass: | |||
else: | |||
protocol, _ = await self.multiselect.negotiate(communicator) | |||
if protocol is None: | |||
raise MultiselectError("fail to negotiate a stream muxer protocol") | |||
raise MultiselectError( | |||
"fail to negotiate a stream muxer protocol: no protocol selected" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fail to negotiate a stream muxer protocol: no protocol selected" | |
"Failed to negotiate a stream muxer protocol: no protocol selected" |
Overall good, just a couple places to update to keep messaging consistent. |
@unniznd : Great work, Aanand. Wish if you could address the feedback points shared by @pacrob. Overall the PR is in good shape. Kindly share a detailed blog (you can open up a discussion page for the same) on how you did this PR once you resolve the above issues. Since this was your initial PRs in py-libp2p, which is getting merged, we would like you to share your experiences from a technical perspective in detail. This would also help the new contributors to take up projects in py-libp2p and arrive at a good conclusion on them. Keep up the wonderful progress. |
@pacrob, I have made the changes. |
@unniznd : Great work, Aanand. This PR is indeed ready for final review + merge. Congratulations on the wonderful progress. Keep it up :) Looking forward to sharing more detailed projects with you this week. @acul71 and @pacrob : Thank you so much for your great support and mentorship. Appreciate it. |
What was wrong?
The multiselect type was inconsistent
How was it fixed?
Set the return type to None and handled the places where the
negotiate
function is used.Reopening the PR #814 due to an error in the rebase.
Summary of approach.
To-Do
Cute Animal Picture