You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(adapters): align discord/linear/teams body extraction with working pattern
CodeRabbit flagged three real bugs in the discord/linear/teams
`_get_request_body` implementations that the github/telegram/whatsapp
fix didn't cover:
- `str(await result if ... else result)` wrong-stringifies bytes returned
from a callable `request.text()` (e.g. `str(b"...") -> "b'...'"`).
- Non-callable `request.text` holding `bytes`/`bytearray` returns raw
bytes to a `-> str` signature, typecheck lie + caller breaks.
- `data` fallback missed `bytearray` (matches the earlier text/body
bytes-vs-bytearray fix).
- `read()` was only awaited via `iscoroutinefunction(raw_read)`, which
misses wrapped/decorated methods that return an awaitable. Switched
to `inspect.isawaitable(raw_result)` on the call result.
Restructured all three to match the text-first shape used by the static
adapters (github/telegram/whatsapp) and marked them `@staticmethod` —
`self` was unused and consistency avoids future regressions.
Tests: extended `test_request_body_extraction.py` matrix from 3 adapters
to 6 and added `test_handles_sync_callable_body` for the previously
unexercised sync body() branch. Dropped the broad `except ImportError:
pass` guard — every adapter lazy-imports platform deps inside methods,
so direct imports work and a broken adapter module now fails the suite
instead of silently skipping (matches the "every test must fail when
the code is wrong" rule).
54 parametrized cases (9 shapes × 6 adapters) — all passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments