Skip to content

fix(decoder): render array and tuple params element-wise in alerts - #382

Merged
spalen0 merged 2 commits into
mainfrom
fix/telegram-bytes-params
Sep 25, 2026
Merged

spalen0 merged 2 commits into
mainfrom
fix/telegram-bytes-params

Conversation

@spalen0

@spalen0 spalen0 commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

In the Infinifi Longtimelock alert (tx 0x86da39a4959d9dcebfdec6f9840db083f5a4474bbc9cbb49a064e1105283635f), the grantRoles(bytes32[],address[]) call showed its parameters as raw Python values:

├ bytes32: (b'2\xe7\xb1\xb8\xf9M\x17\xccWO\xbfS...', b'6S\xdaB@\x9a0...', ...)
├ address: ('0x579b18e60d0245c0f66fa9463610b15e226ae8fd', ...)

_format_param_value only handled single values, so arrays and tuples were printed with str(). On top of that, one role id's b'...' form contains a backtick. That closed the Markdown code span early, so Telegram mangled the rest of the line (dropping the [] from the type) and could reject the whole message with a 400 "can't parse entities" error.

Now:

├ bytes32[]: `[0x32e7b1b8…6525, 0x3653da42…ca3c, 0x7acae897…c960, 0xc46edb82…1546]`
├ address[]: `[0x579B18E60d0245c0F66Fa9463610b15E226Ae8FD, …, 0x68Afd386D2A882D3aFCBfC1586AE722568052FF6]`

(Shortened here; the alert shows the full values.)

  • Arrays (T[], T[k]) and tuples ((a,b,…), including nested ones) are formatted element by element using each element's own type: bytes as 0x hex, addresses checksummed.
  • A bytes32 holding a short text string padded with zero bytes is also shown as that text, e.g. 0x5553…00 ("USDC"). Hashes such as role ids stay hex only.
  • Backticks inside string values are replaced, and values of unknown type never print Python's b'...' form.

Test plan

  • New decoder tests: bytes32[] (with the real role ids), address[], typed tuple arrays, bytes32 text decoding and the hash case, backtick safety, unknown-type bytes
  • Re-rendered the real 13-call batch: every line shows hex and checksummed values, and each line has an even number of backticks
  • uv run pytest tests/ (1388 passed), ruff check, ruff format

🤖 Generated with Claude Code

spalen0 and others added 2 commits September 25, 2026 15:28
bytes32[] / address[] params fell through to str(), printing Python
b'...' reprs and lowercase address tuples. A repr containing a backtick
also closed the Telegram Markdown code span early, mangling the alert.
Render arrays and tuples per element (bytes as hex, addresses
checksummed), decode zero-padded ASCII bytes32 strings, and strip
backticks from rendered values.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Route the non-bytes branches of bytes32/bytesN through the untyped
renderer so no path skips backtick sanitization, test the tuple
length-mismatch fallback, and document why single-character bytes32
values stay hex-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@spalen0
spalen0 marked this pull request as ready for review September 25, 2026 13:39
@spalen0
spalen0 merged commit 7c1f312 into main Sep 25, 2026
3 checks passed
@spalen0
spalen0 deleted the fix/telegram-bytes-params branch September 25, 2026 14:07
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.

1 participant