fix(telegram): cool down transient sendChatAction failures#55886
fix(telegram): cool down transient sendChatAction failures#55886Boulea7 wants to merge 5 commits into
Conversation
Greptile SummaryThis PR adds a transient cooldown path to the Confidence Score: 5/5Safe to merge — the transient cooldown path is correctly implemented, all key scenarios are tested, and the 401 suspension contract is preserved. No P0 or P1 issues found. The only comment is a P2 style suggestion about using structured error_code detection for 429 instead of string-matching, which is functionally equivalent for all realistic Telegram error shapes. No files require special attention.
|
| Filename | Overview |
|---|---|
| extensions/telegram/src/sendchataction-401-backoff.ts | Adds transient cooldown state machine alongside existing 401 suspension path; logic and guard ordering are correct. |
| extensions/telegram/src/sendchataction-401-backoff.test.ts | Mock refactored to full factory covering all transitively-used infra-runtime exports; seven new test cases cover all key cooldown paths. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/telegram/src/sendchataction-401-backoff.ts
Line: 74-81
Comment:
**`isRateLimitError` duplicates structured detection already available**
`isRateLimitError` relies on string-matching (`JSON.stringify`) while `isTelegramServerError` (used right below it) uses the typed `error_code` field via `hasTelegramErrorCode`. A 429 response from Telegram carries `error_code: 429`, so it would be detected consistently if `isTransientSendChatActionError` used `hasTelegramErrorCode(error, (code) => code === 429)` (or a new exported `isTelegramRateLimitError`) instead of string-matching. The current approach works for every realistic Telegram error shape (since `JSON.stringify` will always include the number `429`), but introduces a style inconsistency that could drift if error shapes change.
```suggestion
function isRateLimitError(error: unknown): boolean {
return hasTelegramErrorCode(error, (code) => code === 429);
}
```
> Note: `hasTelegramErrorCode` is a file-private helper in `network-errors.ts`. If you prefer to keep the string-fallback for non-structured errors (e.g. raw `Error("429 Too Many Requests")`), consider exporting a dedicated helper from `network-errors.ts` that handles both paths.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(telegram): cool down transient sendC..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78297b3386
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Updated this PR again. Latest follow-ups I addressed:
Fresh local verification:
I also cross-checked the earlier failing PR run against a failing I’m keeping this PR scoped to the Telegram sendChatAction fix and the review follow-ups, and I’ll keep watching the new CI run. |
e902920 to
c4fe168
Compare
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #55886 |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: current main still lacks the central transient Telegram sendChatAction cooldown, and this branch contains useful bug-fix work. It is not merge-ready because it conflicts with current main, narrows current rate-limit fallback behavior, edits release-owned CHANGELOG.md, and lacks real Telegram behavior proof. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main rethrows non-401 transient sendChatAction failures and has no transient cooldown. I did not run a live Telegram outage reproduction in this read-only review. Is this the best way to solve the issue? No, not as submitted. The handler is the right layer for the cooldown, but the branch must preserve current rate-limit/coalescing behavior and provide real Telegram proof before it is the best mergeable fix. Security review: Security review cleared: No concrete security or supply-chain concern found; the diff changes Telegram error handling/tests and a changelog entry without new dependencies, permissions, secrets handling, or code execution surfaces. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against db5e415888ae. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Clownfish 🐠 reef update Thanks for the work on this. Clownfish could not push to this branch with the permissions available, so it opened a narrow replacement PR to keep the fix swimming forward without losing the contributor trail. not your fault, just GitHub branch-permission tides. Replacement PR: #93020 fish notes: model gpt-5.5, reasoning xhigh; reviewed against 5b4b09f. |
|
Clownfish 🐠 landed Thanks for the report and context here. This is superseded by #93020, which has landed as the canonical Clownfish fix path for this cluster. Closing this now that the validated fix has landed. If current main still shows a different path, reply here and we can reopen. fish notes: model gpt-5.5, reasoning medium; reviewed against 6134c00. |
Summary
sendChatActionfailures (network / 429 / temporary 5xx) can keep firing repeatedly, creating noisy retry loops and log spam.sendChatActioncalls until a later recovery.typingModeconfig behavior, message delivery flow, or Telegram channel startup/runtime wiring outside the dedicated handler.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
sendChatActionhandler only had global backoff / suspension behavior for 401s, but transient failures still retried on every later call path.git blame, prior PR, issue, or refactor if known): the current per-account guard already existed for 401 token failures insendchataction-401-backoff.ts.typingModeconfig propagation as the root cause for this specific issue.Regression Test Plan (if applicable)
extensions/telegram/src/sendchataction-401-backoff.test.tsextensions/telegram/src/send.test.ts -t "sends typing"still covers the normal typing send seam.User-visible / Behavior Changes
sendChatActionfailures no longer keep retrying on every call path.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoRepro + Verification
Environment
Steps
sendChatActionfailures.Expected
Actual
Evidence
Human Verification (required)
401 -> transient -> 401sequence preserves 401 counterDate.now-driven cooldown expiry pathtypingModeconfiguration behaviorReview Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
🤖 AI-assisted (Codex), tested with focused local verification