Skip to content

fix(telegram): redact bot tokens from poller errors - #4823

Closed
gotnochill815-web wants to merge 1 commit into
Tracer-Cloud:mainfrom
gotnochill815-web:fix/4769-telegram-token-redaction
Closed

fix(telegram): redact bot tokens from poller errors#4823
gotnochill815-web wants to merge 1 commit into
Tracer-Cloud:mainfrom
gotnochill815-web:fix/4769-telegram-token-redaction

Conversation

@gotnochill815-web

Copy link
Copy Markdown

Fixes #4769.

Summary

Prevent Telegram bot tokens from appearing in gateway logs or caller-visible errors when transient HTTP failures occur.

Changes

  • Redact bot tokens from transient getUpdates exceptions before logging.
  • Log the exception type separately for debugging.
  • Redact bot tokens from Telegram HTTP error descriptions.
  • Redact bot tokens from TelegramBotClient transport errors.
  • Add regression tests covering exception, HTTP response, and client error paths.

Testing

  • pytest -q gateway/tests/telegram/test_telegram_poller.py gateway/tests/telegram/test_telegram_client.py - 10 passed
  • ruff check on changed files - passed
  • git diff --check - passed

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR redacts Telegram bot tokens from poller exceptions, Telegram HTTP error descriptions, and client transport errors while retaining exception-type diagnostics.

  • Applies the shared token-redaction helper before errors are logged or returned.
  • Adds regression coverage for poller exception, HTTP response, and client transport-error paths.

Confidence Score: 4/5

The PR appears safe to merge, with only a non-blocking HTTP-status constant convention issue in a new test.

The changed runtime paths redact the configured token before logging or returning the targeted errors, and the only accepted concern is the use of a numeric HTTP status in regression coverage.

Files Needing Attention: gateway/tests/telegram/test_telegram_poller.py

Important Files Changed

Filename Overview
gateway/transports/telegram/poller/client.py Redacts the configured bot token from transport exception strings before they are logged or returned.
gateway/transports/telegram/poller/poller.py Redacts tokens from transient exceptions and failed poll-response descriptions while logging the exception type separately.
gateway/tests/telegram/test_telegram_client.py Adds focused coverage confirming client transport errors no longer expose the token.
gateway/tests/telegram/test_telegram_poller.py Adds effective exception and HTTP-response redaction tests, but the new HTTP response fixture uses a hardcoded status code contrary to repository conventions.

Reviews (1): Last reviewed commit: "fix(telegram): redact bot tokens from po..." | Re-trigger Greptile


token = "123456:SECRET"

mock_get.return_value = httpx.Response(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Hardcoded HTTP status code

The new response fixture uses the numeric status 500 instead of the repository-required named HTTPStatus constant, making the test less self-documenting and inconsistent with the established HTTP-status convention.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@Devesh36

Devesh36 commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Hey @gotnochill815-web someone else is already assigned to this issue. You have to take something else.

@Devesh36 Devesh36 closed this Aug 10, 2026
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.

[BUG] Telegram gateway poller can log/return a live bot token on transient failures

2 participants