Skip to content

Pass unmatched calls through when branch has no fallback - #968

Closed
soroush5 wants to merge 1 commit into
grammyjs:v2from
soroush5:fix/branch-missing-otherwise
Closed

soroush5 wants to merge 1 commit into
grammyjs:v2from
soroush5:fix/branch-missing-otherwise

Conversation

@soroush5

Copy link
Copy Markdown

Fixes #940. (The repro in draft #939 should now pass with this change.)

composer.on("sendMessage") crashed with TypeError: Cannot read properties of undefined (reading 'transformer') for any nonmatching method. Root cause is in branch(): filter() calls it without a fallback, and it built new TransformerComposer(falseTransformer) with falseTransformer === undefined — a one-element chain whose flatten step blows up on undefined.

The fix uses an empty composer (identity pass-through) when no fallback is given, so unmatched calls flow to previous untouched.

How I verified: new test/transform.test.ts — a nonmatching getMe reaches previous exactly once (fails before with the exact reported TypeError, passes after), plus a matching-method test proving scoped transformers still run. Neighbors (composer, filter) green: 5 files / 78 steps, deno lint + deno fmt --check clean.

@soroush5

Copy link
Copy Markdown
Author

You're right, thanks for pointing it out — #956 was already open and covers this. Closing mine to keep the review queue clean; happy to help test or review #956 instead.

@soroush5 soroush5 closed this Sep 10, 2026
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