Skip to content

Making error message clearer when peer_pubkey used and peer is offline#2139

Draft
sergey3bv wants to merge 2 commits into
lightninglabs:mainfrom
sergey3bv:refactor/clean-err-message
Draft

Making error message clearer when peer_pubkey used and peer is offline#2139
sergey3bv wants to merge 2 commits into
lightninglabs:mainfrom
sergey3bv:refactor/clean-err-message

Conversation

@sergey3bv
Copy link
Copy Markdown
Contributor

Should close #1577

@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 improves the user experience by providing clearer feedback when an RFQ flow fails due to a peer being offline. Instead of a generic 'no asset channels found' error, the system now explicitly states that matching channels exist but are currently inactive.

Highlights

  • Improved Error Messaging: Updated the RFQ flow to provide a more descriptive error message when a specific peer is targeted but only inactive channels exist, distinguishing between missing channels and inactive ones.
  • Testing Coverage: Added a new test suite to verify that FetchChannel correctly identifies and reports inactive channels when a peer is offline.
New Features

🧠 You can now enable Memory (public preview) 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 the 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 counterproductive. 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 enhances the RFQ manager's error reporting by providing specific feedback when matching asset channels exist but are inactive, rather than returning a generic 'not found' error. The changes include logic to fetch and filter all channels for a specific peer and a new test case to validate the error messages. Reviewers identified a potential breaking change in addScidAlias due to its reliance on exact error string matching and recommended style improvements, including adding explanatory comments for code intention and using idiomatic range loops.

Comment thread rfq/manager.go
Comment on lines +1294 to +1299
return nil, fmt.Errorf("no active asset "+
"channel for %s and peer=%s: "+
"matching channel(s) are inactive "+
"(peer offline or not usable for "+
"RFQ)", &specifier, peerPubKey)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The new error message introduced here is much clearer for the user. However, please be aware that addScidAlias (lines 633-635) currently uses fragile string matching on errors returned by FetchChannel. Since this new error message does not match the expected string "no asset channel balance found for", it will cause addScidAlias to skip its fallback logic and return an error instead. You should consider updating addScidAlias to handle this new error case or, ideally, refactor the error handling to avoid string matching.

Comment thread rfq/manager.go
if peerPubKey != nil {
_, ok := balancesMap[*peerPubKey]
if !ok {
allChannels, err := m.cfg.ChannelLister.ListChannels(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide (lines 7-8, 51), in-body comments should explain the intention behind a block of code. Adding a brief comment here explaining why we are fetching all channels (to provide a more descriptive error message) would improve maintainability.

			// If we couldn't find an active channel for the peer, we'll
			// check if there are any inactive channels that match the
			// asset specifier. This allows us to provide a more
			// descriptive error message to the user.
			allChannels, err := m.cfg.ChannelLister.ListChannels(
References
  1. Comments must explain the why behind a certain block of code. In-body comments should explain the intention of the code. (link)

Comment thread rfq/manager.go Outdated
Comment on lines +1277 to +1283
for i := range allChannels {
if allChannels[i].PubKeyBytes == *peerPubKey {
peerChannels = append(
peerChannels, allChannels[i],
)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This loop can be simplified by using a value range, which is more idiomatic in Go when the index is not required. This improves readability as per the style guide (line 6).

			for _, channel := range allChannels {
				if channel.PubKeyBytes == *peerPubKey {
					peerChannels = append(peerChannels, channel)
				}
			}
References
  1. Readable code is the most important requirement for any commit created. (link)

@sergey3bv sergey3bv force-pushed the refactor/clean-err-message branch from 680f3ca to 2358cee Compare May 15, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

[bug]: AddInvoice: clearer error message when peer_pubkey used and peer is offline

1 participant