Description
When trying to connect the Hermes agent to Telegram, the connection fails with a 302 Found response from Cloudflare, which triggers a JSONDecodeError because the unexpected HTML response cannot be parsed as JSON.
Despite having the CLOUDFLARE_WORKERS_TOKEN configured, the gateway still encounters this redirection/block from Cloudflare.
Environment
Python Version: 3.13
Platform: Telegram Gateway / Hermes Agent
Date of Occurrence: 2026-06-18
Steps to Reproduce
Configure the Hermes agent with Telegram integration.
Set the CLOUDFLARE_WORKERS_TOKEN environment variable.
Start the agent/gateway.
Observe the connection logs.
Expected Behavior
The agent should successfully authenticate and establish a connection with the Telegram API/Gateway through Cloudflare without being redirected (302).
Actual Behavior / Logs
The gateway fails to connect and enters a retry loop due to a 302 Found HTML response from Cloudflare:
Traceback (most recent call last):
File "/opt/hermes/.venv/lib/python3.13/site-packages/telegram/request/_baserequest.py", line 397, in parse_json_payload
return json.loads(decoded_s)
File "/usr/lib/python3.13/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/usr/lib/python3.13/json/decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/json/decoder.py", line 363, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2026-06-18 08:12:27,519 WARNING gateway.platforms.telegram: [Telegram] Connect attempt 5/8 failed: Found (302). Parsing the server response b'<html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>cloudflare</center>\r\n</body>\r\n</html>\r\n' failed — retrying in 15s
2026-06-18 08:12:42,363 WARNING gateway.run: Reconnect telegram error: telegram connect timed out after 30s, next retry in 300s
Description
When trying to connect the Hermes agent to Telegram, the connection fails with a 302 Found response from Cloudflare, which triggers a JSONDecodeError because the unexpected HTML response cannot be parsed as JSON.
Despite having the CLOUDFLARE_WORKERS_TOKEN configured, the gateway still encounters this redirection/block from Cloudflare.
Environment
Python Version: 3.13
Platform: Telegram Gateway / Hermes Agent
Date of Occurrence: 2026-06-18
Steps to Reproduce
Configure the Hermes agent with Telegram integration.
Set the CLOUDFLARE_WORKERS_TOKEN environment variable.
Start the agent/gateway.
Observe the connection logs.
Expected Behavior
The agent should successfully authenticate and establish a connection with the Telegram API/Gateway through Cloudflare without being redirected (302).
Actual Behavior / Logs
The gateway fails to connect and enters a retry loop due to a 302 Found HTML response from Cloudflare:
Traceback (most recent call last):
File "/opt/hermes/.venv/lib/python3.13/site-packages/telegram/request/_baserequest.py", line 397, in parse_json_payload
return json.loads(decoded_s)