Repository navigation
fix(runtime): readable config error when TELEGRAM_API_ID/HASH are missing - #312
Merged
chigwell merged 1 commit intoOct 16, 2026
Merged
Conversation
…sing Starting the server without TELEGRAM_API_ID crashed with a raw TypeError from int(None) at import time. Validate both credentials (and the integer format) before use and exit with the same message style as the migrator and the session string generator, including a pointer to https://my.telegram.org/apps. Fixes chigwell#300 Co-Authored-By: Claude Code <[email protected]>
chigwell
approved these changes
Oct 16, 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.
Before
Starting the server without
TELEGRAM_API_IDdies with a raw traceback that never mentions what is actually missing:A non-numeric value fails the same way:
The sibling entrypoints (
migrate_session.py,session_string_generator.py) already print a readable message; only the server crashes.After
Same startup now exits with a config error that names the variables and what to do, in the same style as the siblings:
A malformed value gets its own message instead of a
ValueError:What changed
telegram_mcp/runtime.py: the module-levelint(os.getenv("TELEGRAM_API_ID"))is replaced with_require_api_credentials(), which validates presence, non-emptiness, and integer format before use and exits with the messages above. No behavior change when credentials are set correctly.Tests
test_missing_api_credentials_exit_with_readable_error,test_non_integer_api_id_exits_with_readable_errorintests/test_runtime.pyuv run pytest): 1198 passed on the tree with this and the two sibling fixes (migrate_session turns '-' into '_' in account labels; generator and runtime keep the dash #301, save_aliases crashes when TELEGRAM_ALIASES_FILE points into a missing directory #302)Fixes #300
🤖 Generated with Claude Code