Skip to content

fix: normalise routing_path from bytes to list[int] for PacketBuilder compatibility - #99

Merged
cwill747 merged 1 commit into
mainfrom
fix/dm-routing-path-type
Oct 3, 2026
Merged

cwill747 merged 1 commit into
mainfrom
fix/dm-routing-path-type

Conversation

@cwill747

Copy link
Copy Markdown
Owner

Problem

Sending direct messages fails with:

[meshcore_console.ui_gtk.views.message] Send failed: routing_path must be a list, got <class 'bytes'>

Group chat messages are unaffected.

Root cause

MeshcoreClient._seed_contact_book() stored contact.out_path as concatenated bytes via bytes.fromhex(). PacketBuilder.create_text_message() (openhop_core 1.1.3) validates routing_path as a flat list of byte values and rejects bytes.

Changes

Three files (+ new test):

client.py — Store out_path as list[int] instead of bytes in both _seed_contact_book() and _sync_contact_to_book()

contact_book.py — Widen Contact.out_path type annotation to list[int] | bytes | None since openhop_core callbacks still assign bytes

operations.py — Add _text_message_contact() that normalises byte paths to list[int] on a shallow copy before passing to PacketBuilder.create_text_message(), applied in both send_text() and send_repeater_command()

Verification

  • 44 relevant unit tests pass (incl. new test_dm_routing_path.py)
  • ruff check and format pass clean
  • No new mypy errors beyond the 22 pre-existing ones

Closes #98

… compatibility

Direct-message sends failed because contact.out_path was stored as
concatenated bytes (bytes.fromhex) but PacketBuilder.create_text_message
validates routing_path as a flat list of byte values.

Three-part fix:
- Store out_path as list[int] in _seed_contact_book and
  _sync_contact_to_book (client.py)
- Widen the Contact.out_path type annotation to accept both forms
  since openhop_core callbacks still assign bytes (contact_book.py)
- Normalise byte paths via _text_message_contact() on a shallow copy
  in send_text and send_repeater_command (operations.py)

Fixes #98
@cwill747
cwill747 merged commit ad5ce2a into main Oct 3, 2026
9 checks passed
@cwill747
cwill747 deleted the fix/dm-routing-path-type branch October 3, 2026 20:09
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.

Error sending direct messages

1 participant