Repository navigation
feat(errors): say whether a retry can work, and what to run - #177
Merged
neoromantic merged 1 commit intoNov 18, 2026
Merged
neoromantic merged 1 commit into
neoromantic merged 1 commit into
Conversation
Every error has retryable: true when the same command, run again unchanged, can succeed (a rate limit after its wait, a network error, a download waiting on another tg process), false otherwise. A rate limit suggests the wait, which stays in details.wait_seconds; the nine copies of that block are one helper. An unknown --account and a numeric --to Telegram refuses suggest what to run. Codes, exit codes and messages are unchanged. Refs neoromantic#160 Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 18, 2026
Merged
This was referenced Nov 18, 2026
ertembiyik
pushed a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
Resolves the conflicts with neoromantic#176/neoromantic#177 in CHANGELOG.md (both sections kept) and src/commands/messages/search.ts (success(data, next) from main, the snippet from the rendered item text from neoromantic#178). Co-Authored-By: Claude Opus 5.5 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
CHANGELOG: both sides' entries kept. Per-file error lines carry retryable (neoromantic#177) and the shared rate-limit wording. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
added a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
helpers.ts: a message item gets the transcript and the rich text (neoromantic#186). CHANGELOG: both sides' entries kept. Per-message error lines and the docs example carry retryable (neoromantic#177). Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 18, 2026
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.
What and why
Point 2 of #160. Every error now says whether running the same command again can work (
error.retryable), and a rate limit says how long to wait before that, so an agent retries a flood wait instead of giving up or retrying blindly. The errors that had something actionable to say also suggest what to run. Refs #160Before (
tg api help.getNearestDcduring a flood wait, exit 5):{ "success": false, "error": { "code": "RATE_LIMITED", "message": "Rate limited for help.getNearestDc. Wait 42s before retrying.", "details": { "method": "help.getNearestDc", "wait_seconds": 42 } } }After:
{ "success": false, "error": { "code": "RATE_LIMITED", "message": "Rate limited for help.getNearestDc. Wait 42s before retrying.", "details": { "method": "help.getNearestDc", "wait_seconds": 42 }, "suggestion": "Wait 42s, then run the same command again", "retryable": true } }A refused call says the opposite (
tg api help.getNothing):{ "code": "TELEGRAM_ERROR", "message": "API call failed: METHOD_INVALID", "details": { "method": "help.getNothing", "telegramErrorCode": 400 }, "retryable": false }Two errors that gained a suggestion:
tg chats list --account 99(ACCOUNT_NOT_FOUND)Run tg accounts list to see the accounts, then pass an ID, @username or label to --accounttg send --to 123456 -m hello(PEER_ID_INVALID)Send to the user's @username or +phone once: tg caches the user, and its ID works after thatAll output above is real, from the e2e fixtures with the fake client.
What changed:
retryableis on every error. It istrueforRATE_LIMITED(after the wait),NETWORK_ERROR, and a media download that timed out waiting for anothertgprocess's lock;falsefor everything else.details.wait_seconds, with no second copy. All rate-limit sites already put it there; the docs now say it is always present onRATE_LIMITED.RATE_LIMITEDblock in the commands are nowreportRateLimit(err), and the two media cases share one builder, so the message, details and suggestion can't drift apart.--messagetext or a path.Compatibility: codes, exit codes, messages and existing fields are unchanged. The one visible difference is the new key, so a script that deep-compares a whole error object would notice; five of the repo's own e2e assertions did, and are updated.
Counts on
mainatc44c203, by call site: 28 of 146error()calls carried a suggestion; now 37 of 138 (fewer calls because of the helper).RATE_LIMITEDwent from 0 of 9 to all of them,ACCOUNT_NOT_FOUNDfrom 0 of 8 to 7 of 8. I leftINVALID_ARGSalone because almost every message already names the fix, and theTELEGRAM_ERRORcatch-alls because there is nothing to add to Telegram's own text. TheUnknown object undefinedcase from the issue is already fixed in 0.13.1.Decisions you may want to change:
retryableis a fifth positional argument oferror()with a default per code. An options object would read better if more overrides appear.TELEGRAM_ERRORis alwaysretryable: false, including Telegram's 500 and -503, which may pass on a retry. Classifying those needs the RPC error at each catch-all.Found on the way, not changed here:
tg meturns any failure ofgetMeintoAUTH_REQUIRED, so a network error there reports "not authorized".INVALID_ARGS. Agents probably hit that more than any other argument error.This touches
src/utils/output.tsandsrc/commands/send.ts, as #176 and #175 do. I'll rebase whichever of the three lands later.How I checked it
New e2e tests in
src/__e2e__/api.e2e.test.tsdrive the fake client to answerFLOOD_WAIT_42(twice: the second run fails before calling Telegram, with the same shape) andPEER_ID_INVALID, and assert the retry signal, the wait and the exact suggestions.accountsandmulti-accounte2e tests cover the account suggestions.Unit tests for
error(), the account selector, the media download errors and the history command.Not verified: the exact error the failed parallel downloads in the issue printed; I can't reproduce those sessions. Both ways a flood wait reaches a download are tested.
bun run check: clean.bun run test: 2304 pass, 0 fail.bun run test:e2e: 437 pass, 0 fail.Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard (
docs/api-design.md,docs/cli-commands.md,docs/rate-limiting.md,docs/media.md, README, the schema line inAGENTS.md, CHANGELOG)Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code