Skip to content

fix(trace): stop mis-parsing ROUTING_APP as RouteDiscovery - #3

Merged
chrishaef merged 1 commit into
mainfrom
cursor/fix-trace-routediscovery-6035
Oct 18, 2026
Merged

chrishaef merged 1 commit into
mainfrom
cursor/fix-trace-routediscovery-6035

Conversation

@chrishaef

Copy link
Copy Markdown
Owner

Summary

!trace increasingly failed with:

Trace fehlgeschlagen: Error parsing message with type 'meshtastic.protobuf.RouteDiscovery'

Root cause: format_traceroute_packet always ran RouteDiscovery.ParseFromString on decoded.payload. Traceroute wantResponse failures often arrive as ROUTING_APP. A Routing message with nested route_request (length-delimited field 1) is not valid RouteDiscovery wire data (field 1 = repeated fixed32), so protobuf raises DecodeError / “Wire format was corrupt”. That exception was wrapped by _run_trace_job into the German “Trace fehlgeschlagen” string.

Same class of bug as upstream meshtastic/python#930. Reproduced with meshtastic==2.7.11 + protobuf 7.x.

Fix (modules/trace.py):

  • Detect ROUTING_APP and return a short DE routing-error DM (never parse as RouteDiscovery)
  • Prefer library-predecoded decoded.traceroute when present
  • Catch DecodeError → clear DE “Antwort unlesbar” message (no raw protobuf text to users)
  • Coerce base64 string payloads if needed

Tests: modules/test_trace.py (mock packets, no radio)

Test plan

  • python3 -m unittest modules.test_trace -v
  • Manual !trace on a live node after deploy (success path + unreachable / MAX_RETRANSMIT)
  • Docs / config.template — N/A (behaviour-only; CHANGELOG updated)
  • No secrets or local config.ini included

Notes / caveats

  • requirements.txt leaves meshtastic unpinned; keep the Python lib roughly aligned with node firmware / meshtasticd.
  • Separate host/firmware issue: torn FromRadio frames when debug-log-over-API is enabled can also cause protobuf parse errors — this PR only hardens the bot’s traceroute decode path.
  • Do not merge unless asked.
Open in Web Open in Cursor 

wantResponse failures can arrive as ROUTING_APP (nested route_request),
which DecodeError'd when parsed as RouteDiscovery and surfaced as
"Trace fehlgeschlagen: Error parsing message...". Prefer predecoded
traceroute dicts, map routing errors to short DE replies, and add
unittest coverage without radio.

Co-authored-by: chrishaefner <chrishaefner@outlook.de>
@github-actions

Copy link
Copy Markdown

Danke für den Pull Request!

Kurzchecklist: Fokus halten, keine Secrets committen, bei Verhaltens-/Config-Änderungen README oder config.template mitziehen, Tests wo sinnvoll (pytest modules/test_blitzwatch.py).

Leitfaden: CONTRIBUTING.md.

@chrishaef
chrishaef marked this pull request as ready for review October 18, 2026 11:25
@chrishaef chrishaef self-assigned this Oct 18, 2026
@chrishaef chrishaef added the bug Something isn't working label Oct 18, 2026
@chrishaef
chrishaef merged commit 334ccb8 into main Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant