Skip to content

fix(settings): Telegram token save no longer shows "Save failed: 10" - #149

Open
Hiddify-Official wants to merge 1 commit into
hiddify:devfrom
Hiddify-Official:fix/telegram-token-save
Open

Hiddify-Official wants to merge 1 commit into
hiddify:devfrom
Hiddify-Official:fix/telegram-token-save

Conversation

@Hiddify-Official

Copy link
Copy Markdown
Contributor

Problem

Many admins report that saving a Telegram bot token in Settings shows Saved successfully followed by Save failed with just "10".

Root cause: the "bot connected" toast was Telegram bot connected: @{username}, and in vue-i18n @ starts a linked message. Compiling it threw CompileError 10 ("Invalid linked format") right after the settings had been saved and the bot connected, so the save's catch showed the generic "Save failed: 10". The token was in fact saved, and the bot worked.

Change

  • settings.telegramConnected in all 7 languages: @ is the literal {'@'}. Every adminV2 string was compile-checked with @intlify/message-compiler; no other used message has this problem.

  • features/settings/telegram-error.ts + SettingsView.vue: when the bot really does not connect, a card above the settings explains why in plain words, with numbered steps:

    • Telegram did not accept the token (401/404): get it again from BotFather.
    • The server cannot reach api.telegram.org: a timeout or DNS failure, e.g. where Telegram is filtered on the server's own network. register_bot reports these as "Invalid token: …" too, so they are matched first.
    • Telegram cannot use the panel's address for the webhook: a domain with a valid certificate is needed.
    • Other errors get generic steps.

    Telegram's message is under Technical details, and the error toast points to the card. New settings.tgError.* strings in 7 languages.

Screenshots

The save was answered by the test browser itself, so main's real token was never changed. The token typed in is a dummy.

Before After
before after
before after

The server cannot reach Telegram (Persian): network

Tested

  • On main, with a successful connect: before, "Save failed: 10", exactly as reported; after, only "Telegram bot connected: @example_bot".
  • With a rejected token, and with an unreachable api.telegram.org: the matching card and steps are shown.
  • baseCompile on the old message gives error 10, and on the new one no error. vue-tsc: no errors in the changed files.
  • Not tested: a live connect with a real bot token. The fix is in the toast text, which runs after the connect.

Review

  • Confidence: High (>90%) — the error is reproduced exactly (code 10) and the fix is one translation string; the card is UI only.
  • Complexity: Simple — Settings page and translations; no backend change.

🤖 Generated with Claude Code

…d: 10"

The "bot connected" toast read "…: @{username}". In vue-i18n "@" starts a
linked message, so compiling it threw CompileError 10 ("Invalid linked
format") right after the settings had been saved and the bot connected:
the save's catch then showed "Save failed" with "10". The "@" is the
literal {'@'} now, in every language (the only such message left in the
admin UI).

When the bot really does not connect, a card above the settings says why
in plain words with numbered steps (token not accepted, the server cannot
reach Telegram, Telegram cannot use this panel's address, other), with
Telegram's message under Technical details; the toast points to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@dxnnystyles dxnnystyles left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a small table-driven test for
telegramErrorKind? the network-first check keeps a
wrapped Invalid token: … timeout from telling admins
to replace a valid token during an outage. the contributing
guide asks for tests + 100% coverage, but i don't see
classifier coverage in this diff.

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.

2 participants