Skip to content

fix(data): bind admin writes to the transport session they were issued under - #7964

Merged
jamesarich merged 1 commit into
mainfrom
fix/admin-send-session-binding
Nov 8, 2026
Merged

jamesarich merged 1 commit into
mainfrom
fix/admin-send-session-binding

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

An admin write carries the passkey of one transport session, but the outbound path only checked "radio is connected" at admission and dispatch. A write queued behind a radio switch could go out through the replacement transport, addressed to the old radio's node number. The queue already honors ConnectionLifecycle.version for callers that pass it (sendAdminForConnection, used by the post-handshake seed); the rest of the admin path did not.

🔧 Changes

  • CommandSender.sendAdmin and sendAdminAwaitResult bind to the lifecycle version current at the call; a stale version is rejected at admission or dispatch like a disconnect (PacketQueueRejectedException, or a non-accepted TRANSPORT_STOPPED result).
  • editSettings captures one version at entry and carries it through begin, every write and the commit, so a switch mid-transaction rejects the rest instead of splitting it across radios.
  • New sendAdminAwaitResultForConnection on CommandSender and sendToRadioAndAwaitResultForConnection on PacketHandler for the awaited path; sendAdminImmediate stays unbound because it exists for mid-handshake sends.

version bumps on every state change, so a queued admin write no longer survives a disconnect/reconnect on the same radio either; the caller sees the failed save.

✅ Testing Performed

  • CommandSenderImplTest: sendAdmin and sendAdminAwaitResult forward the current version; the explicit variant forwards the caller's.
  • PacketHandlerImplTest: an awaited send captured under a stale version reports TRANSPORT_STOPPED without dispatching.
  • RadioControllerImplTest: begin, writes and commit all carry the entry version after the transport moved on.

Closed structurally; the window was not reproduced on a bench.

…d under

An admin write carries one session's passkey, but the outbound path only
checked that a radio was connected, so a write queued behind a radio switch
could leave through the replacement transport. sendAdmin and
sendAdminAwaitResult now carry the lifecycle version current at the call,
and editSettings carries one version through begin, every write and the
commit; a stale version is rejected like a disconnect.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b31b127 and 13d11f5.

Files selected for processing: 9

  • core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/CommandSenderImpl.kt
  • core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/PacketHandlerImpl.kt
  • core/data/src/commonTest/kotlin/org/meshtastic/core/data/manager/CommandSenderImplTest.kt
  • core/data/src/commonTest/kotlin/org/meshtastic/core/data/manager/PacketHandlerImplTest.kt
  • core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/CommandSender.kt
  • core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/PacketHandler.kt
  • core/service/src/commonMain/kotlin/org/meshtastic/core/service/AdminControllerImpl.kt
  • core/service/src/commonTest/kotlin/org/meshtastic/core/service/RadioControllerImplTest.kt
  • core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeCommandSender.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the bugfix PR tag label Nov 8, 2026
@jamesarich
jamesarich marked this pull request as ready for review November 8, 2026 19:09
@jamesarich
jamesarich enabled auto-merge November 8, 2026 19:11
@jamesarich
jamesarich added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 6c522e9 Nov 8, 2026
14 checks passed
@jamesarich
jamesarich deleted the fix/admin-send-session-binding branch November 8, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant