Skip to content

Stop request URLs, and the Telegram bot token in them, reaching the log - #49

Merged
ggapp1 merged 2 commits into
mainfrom
fix/httpx-request-log-leak
Nov 16, 2026
Merged

ggapp1 merged 2 commits into
mainfrom
fix/httpx-request-log-leak

Conversation

@ggapp1

@ggapp1 ggapp1 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

dudamel run configures the root logger at INFO (DEBUG with --debug). Several third-party loggers print credentials at those levels:

  • httpx logs every request's full URL at INFO. python-telegram-bot puts the bot token in the URL path, so with Telegram enabled the token was written to the terminal/journal on every poll. Reproduced: INFO:httpx:HTTP Request: POST https://api.telegram.org/bot<token>/getMe ....
  • httpx2 / httpcore2 — the copies vendored by the MCP SDK, logging under their own names — log MCP server URLs at INFO, including tokens in the query string or userinfo.
  • telegram.Bot logs the Bot API base URL, token included, at DEBUG on construction.
  • mcp.client.streamable_http logs the server-issued session id at INFO.

QUIET_LOGGERS in cli.py holds each at the lowest level that no longer prints the secret, applied even under --debug.

Tests: run and run --debug drive a real telegram.Bot construction plus real httpx and httpx2 clients (MockTransport) with the token in the URL, captured at DEBUG on the root logger (at caplog's default level the INFO line is never collected and the test would pass with the leak live). Removing any one of the httpx, httpx2 or telegram.Bot entries makes it fail. A second test checks every entry is applied. An autouse conftest fixture restores those logger levels after each test, since several existing tests drive run.

1170 tests pass; ruff check and format clean.

… (the Telegram bot token among them) stop reaching the log
…oken-bearing debug lines and the MCP session-id line; restore logger levels after every test
@ggapp1
ggapp1 merged commit e8ade6b into main Nov 16, 2026
6 checks passed
@ggapp1
ggapp1 deleted the fix/httpx-request-log-leak branch November 16, 2026 19:07
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.

1 participant