Skip to content

rpc: improve ConnectPeer error message when no host provided#10675

Open
TechLateef wants to merge 2 commits intolightningnetwork:masterfrom
TechLateef:fix/connectpeer-no-host-error
Open

rpc: improve ConnectPeer error message when no host provided#10675
TechLateef wants to merge 2 commits intolightningnetwork:masterfrom
TechLateef:fix/connectpeer-no-host-error

Conversation

@TechLateef
Copy link
Copy Markdown

Summary

Fixes #10617

When ConnectPeer is called with only a pubkey and no host address, it now returns a descriptive error message "no addresses known for peer <pubkey>" instead of a generic EOF error.

Changes

  • Added host validation check in ConnectPeer RPC method
  • Returns proper gRPC InvalidArgument status with descriptive message
  • Added unit test to verify the new error behavior

Testing

  • Added TestConnectPeerNoHost test case
  • All existing tests continue to pass
  • Verified error message format follows LND conventions

This helps clients distinguish this failure case and guide users appropriately (e.g., "try providing host:port directly").

When ConnectPeer is called with only a pubkey and no host address,
return a descriptive error message 'no addresses known for peer <pubkey>'
instead of a generic EOF error. This helps clients distinguish this
failure case and guide users appropriately.

Fixes lightningnetwork#10617
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience for the ConnectPeer RPC by providing a more informative error message when a connection attempt is made without specifying a host address. Previously, such attempts resulted in a vague EOF error, making it difficult for clients to diagnose the issue. The change introduces explicit validation and returns a clear InvalidArgument gRPC status, guiding users to provide the necessary host information.

Highlights

  • Improved Error Handling: The ConnectPeer RPC method now returns a descriptive InvalidArgument gRPC error when a host address is not provided, replacing a generic EOF error.
  • Host Validation: A new validation check was introduced in the ConnectPeer method to explicitly detect and handle cases where the Addr.Host field is empty.
  • New Unit Test: A dedicated unit test, TestConnectPeerNoHost, was added to ensure the correct error message and gRPC status are returned when a peer connection is attempted without a host.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new validation check in the ConnectPeer RPC endpoint to ensure that a host address is provided. If the host is empty, an InvalidArgument gRPC error is returned with a descriptive message. A new unit test, TestConnectPeerNoHost, has been added to verify this error handling. The reviewer suggests using status.Errorf directly for improved readability and idiomatic Go when constructing the gRPC status error.

Use status.Errorf instead of status.Error with fmt.Sprintf for better
readability and more idiomatic gRPC error handling.
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@TechLateef, remember to re-request review from reviewers when ready

@TechLateef
Copy link
Copy Markdown
Author

@saubyk Could you please take a look at this when you have a chance?

this implements:
host validation check in ConnectPeer RPC method
Returns proper gRPC InvalidArgument status with descriptive message
Added unit test to verify the new error behavior

addresses issue #10617

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: Improve error message when connecting peer with unknown address

2 participants