fix(telegram): preserve this on adapter.telegramFetch (v0.5.35 regression)#139
Merged
Conversation
v0.5.35 regression: postRich extracted telegramFetch as a plain reference (`const fn = adapter.telegramFetch; fn(...)`) which loses `this`. The real @chat-adapter/telegram telegramFetch is a class method that depends on `this.apiBaseUrl` and `this.botToken` — detached calls throw 'Cannot read properties of undefined (reading apiBaseUrl)'. The catch swallowed the error and silently fell back to plain text, breaking inline keyboards for /model and /topic. Fix: invoke as `tgAdapter.telegramFetch(...)` so `this` is preserved. Live verified on prod: bound call works, detached throws. Mutation-tested regression in test/telegram-postrich.test.ts using a FakeTelegramAdapter that touches `this.apiBaseUrl` (vi.fn() can't catch this — no this-dependence). Reverting the fix → test fails exactly on the 'menu was sent' assertion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Hotfix for v0.5.35. Inline keyboards for
/modeland/topicregressed to text fallback after the Rich UI Surface migration.Root cause:
The real
@chat-adapter/telegramtelegramFetchis a class method that usesthis.apiBaseUrlandthis.botToken. Detached calls throwCannot read properties of undefined (reading apiBaseUrl)— butpostRich's catch swallows it and falls back to text. Live verified on prod:Fix: Invoke as
tgAdapter.telegramFetch(...)sothisis preserved.Why tests didn't catch it: Existing tests mock
telegramFetchasvi.fn()which has nothis-dependence. Added a regression test usingFakeTelegramAdapterthat touchesthis.apiBaseUrland throws when detached. Mutation-tested: revert fix → test fails exactly on the 'menu was sent' assertion.Test: 562 green (+1).
Will tag v0.5.36 + publish on merge.