Skip to content

PeerHelper: deduplicate self node in peer list to fix LazyColumn crash - #840

Open
D-Fed11 wants to merge 1 commit into
tailscale:mainfrom
D-Fed11:fix/lazy-column-duplicate-key
Open

PeerHelper: deduplicate self node in peer list to fix LazyColumn crash#840
D-Fed11 wants to merge 1 commit into
tailscale:mainfrom
D-Fed11:fix/lazy-column-duplicate-key

Conversation

@D-Fed11

@D-Fed11 D-Fed11 commented Aug 21, 2026

Copy link
Copy Markdown

Problem

The Android app crashes immediately on launch with headscale servers:

java.lang.IllegalArgumentException: Key "27" was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.

Root cause

PeerHelper.regenerateGroupedPeers() iterates over (peers + selfNode). With headscale, selfNode is already present in netmap.Peers, so it gets added twice. Both entries share the same StableID, which becomes a duplicate key in MainView's LazyColumn.

Fix

distinctBy { it.StableID } on the combined list before iterating.

Testing

Verified working on Raspberry Pi 4 running LineageOS TV, authenticated against a headscale server. Before fix: crash on every launch. After fix: UI loads and functions correctly.

Refs

With headscale servers, selfNode can already be present in
netmap.Peers, causing it to appear twice in (peers + selfNode).
Both entries share the same StableID, which triggers a
KeyAlreadyUsed IllegalArgumentException in the MainView
LazyColumn, crashing the app on launch.

Fix by deduplicating on StableID before iterating.

Verified working on Raspberry Pi 4 with headscale.

Closes #20725
Ref tailscale#832
@bradfitz

Copy link
Copy Markdown
Member

Closes #20725 ... that doesn't link anything. You mean tailscale/tailscale#20725: tailscale/tailscale#20725

But why is Headscale doing that?

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.

2 participants