Skip to content

Conversation

@fresh3nough
Copy link

@fresh3nough fresh3nough commented Jan 21, 2026

Change Description

Fixes #10447.

Under rare conditions, a local channel can exist in the graph DB with edge
information but without an associated edge policy. When
lncli updatechanpolicy --create_missing_edge is used, routing/localchans
should recreate the missing edge policy.

Previously, the UpdatePolicy flow would still mark those channels as a policy
update failure (NOT_FOUND), preventing the missing-edge creation path from
running.

This PR keeps those channels in unprocessedChans when createMissingEdge is
set, allowing the later missing-edge creation logic to handle them, and adds
unit tests covering both createMissingEdge=true and createMissingEdge=false.

Steps to Reproduce

This issue is easiest to reproduce via the unit test case added in this PR:

# Check out this PR branch.
git checkout fix/10447-missing-local-channel-graph-data

# Re-introduce the pre-fix behavior by temporarily restoring the old
# implementation file from master.
git checkout master -- routing/localchans/manager.go

# This should FAIL (the channel is incorrectly marked NOT_FOUND even though
# createMissingEdge is enabled).
go test ./routing/localchans -run 'TestManager/nil_edge_policy_recreated' -count=1

# Restore the fixed implementation and re-run (should PASS).
git checkout HEAD -- routing/localchans/manager.go
go test ./routing/localchans -run 'TestManager/nil_edge_policy_recreated' -count=1

Steps to Test

# Quick targeted run.
go test ./routing/localchans -run TestManager -count=1

# Or, using the Makefile.
make unit pkg=./routing/localchans case=TestManager timeout=5m

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@gemini-code-assist
Copy link

Summary of Changes

Hello @fresh3nough, 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 addresses an issue where the UpdatePolicy function in the local channels manager would prematurely mark channels as failed if their edge policy was missing, even when there was an intention to create or recreate these missing edges. The changes introduce a conditional mechanism to defer the failure of such channels, allowing them to be processed by a createMissingEdge logic. This ensures that local channel graph data can be more robustly maintained, preventing valid channels from being incorrectly excluded from policy updates due to temporary data inconsistencies.

Highlights

  • Conditional Edge Policy Handling: The UpdatePolicy function now conditionally handles channels with missing edge policies. If a createMissingEdge flag is true, these channels are temporarily held for further processing instead of being immediately flagged as failed updates.
  • Enhanced Test Coverage: The test suite for the Manager has been expanded to include specific edgePolicy definitions within test channels and new test cases that validate the behavior of UpdatePolicy when createMissingEdge is enabled or disabled for channels with initially missing edge policies.

🧠 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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 fixes an issue where missing graph data for local channels was not handled correctly when updating policies. The change in routing/localchans/manager.go correctly defers handling of channels with missing edge policies to a later stage when createMissingEdge is true, allowing for their recreation.

The accompanying tests in routing/localchans/manager_test.go are extended to cover these new scenarios. However, I've found an issue in the test mock for forAllOutgoingChannels that prevents the new test cases from actually testing the intended edge == nil scenario. My review includes a comment with details on this. Once the test is fixed, this PR should be good to go.

Comment on lines +134 to +139
// Use the channel's specific edge policy if set,
// otherwise use the default current policy.
edgePolicy := c.edgePolicy
if edgePolicy == nil && len(c.edgeInfo.ChannelPoint.Hash) != 0 {
edgePolicy = &currentPolicy
}

Choose a reason for hiding this comment

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

high

The logic in this mock for forAllOutgoingChannels seems to prevent the new test cases from correctly testing the edge == nil scenario. The new tests ("nil edge policy recreated" and "nil edge policy not recreated") are intended to test the case where ForAllOutgoingChannels provides a nil edge policy. However, the current logic assigns &currentPolicy to edgePolicy when c.edgePolicy is nil and the channel point is valid. This means the if edge == nil block in manager.go is not actually exercised by these tests.

To ensure the new logic in manager.go is tested, this mock should be updated to allow passing a nil policy to the callback cb for the relevant test cases.

@Abdulkbk
Copy link
Contributor

It's important that you read the contribution guide and review other PRs to see how it's done.

fresh3nough added a commit to fresh3nough/lnd that referenced this pull request Jan 22, 2026
Add release notes entry for the bug fix that addresses missing graph
data for local channels, which was preventing channels from being used
for sending or forwarding payments.

Co-Authored-By: Warp <agent@warp.dev>
@fresh3nough
Copy link
Author

I've updated the PR to follow the contribution guidelines:

✅ Added a detailed Change Description with reference to issue #10447
✅ Added comprehensive Steps to Test section with both manual and automated testing instructions
✅ Added release notes entry in docs/release-notes/release-notes-0.21.0.md
✅ Included the complete Pull Request Checklist

The PR is now ready for review.

@fresh3nough fresh3nough changed the title Fix missing graph data for local channels routing: fix missing graph data for local channels Jan 23, 2026
Co-Authored-By: Warp <agent@warp.dev>
fresh3nough added a commit to fresh3nough/lnd that referenced this pull request Jan 23, 2026
Add release notes entry for the bug fix that addresses missing graph
data for local channels, which was preventing channels from being used
for sending or forwarding payments.

Co-Authored-By: Warp <agent@warp.dev>
@fresh3nough fresh3nough force-pushed the fix/10447-missing-local-channel-graph-data branch from 573d1ca to 40396c5 Compare January 23, 2026 19:43
Co-Authored-By: Warp <agent@warp.dev>
@fresh3nough fresh3nough force-pushed the fix/10447-missing-local-channel-graph-data branch from 40396c5 to a99bb49 Compare January 23, 2026 19:43
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.

Graph data for local channels sometimes missing

2 participants