Skip to content

Telegram storage: uploads always fail with [Telegram API] 400 Bad Request while bot works fine via API #63

@mihallsar

Description

@mihallsar

Hi, and thanks for this awesome project!

I'm trying to use Pentaract as a Telegram-based storage on my local machine (macOS, Docker, thedominux/pentaract:latest).

Environment:

  • OS: macOS (Intel MacBook)
  • Run method: docker compose with prebuilt image
  • Pentaract image: thedominux/pentaract:latest
  • DB: postgres:15.0-alpine
  • Telegram: bot + private channel

Relevant config:

  • docker-compose.yml:

    version: "3.9"
    
    volumes:
      pentaract-db-volume:
        name: pentaract-db-volume
    
    networks:
      pentaract-network:
        name: pentaract-network
    
    services:
      pentaract:
        container_name: pentaract
        image: thedominux/pentaract:latest
        env_file:
          - .env
        ports:
          - "8080:8000"
        restart: unless-stopped
        depends_on:
          - db
        networks:
          - pentaract-network
    
      db:
        container_name: pentaract_db
        image: postgres:15.0-alpine
        environment:
          POSTGRES_USER: pentaract
          POSTGRES_PASSWORD: pentaract_pass
          POSTGRES_DB: pentaract
        restart: unless-stopped
        healthcheck:
          test: pg_isready --username=pentaract --dbname=pentaract
          interval: 10s
          timeout: 5s
          retries: 10
        volumes:
          - pentaract-db-volume:/var/lib/postgresql/data
        networks:
          - pentaract-network

.env (DB and Telegram‑related part):

text
SUPERUSER_EMAIL=...@...
SUPERUSER_PASS=...

TELEGRAM_API_BASE_URL=https://api.telegram.org

DATABASE_USER=pentaract
DATABASE_PASSWORD=pentaract_pass
DATABASE_NAME=pentaract
DATABASE_HOST=db
DATABASE_PORT=5432

POSTGRES_USER=pentaract
POSTGRES_PASSWORD=pentaract_pass
POSTGRES_DB=pentaract

PENTARACT_DB_HOST=db
PENTARACT_DB_PORT=5432
PENTARACT_DB_USER=pentaract
PENTARACT_DB_PASSWORD=pentaract_pass
PENTARACT_DB_NAME=pentaract

PENTARACT_HTTP_PORT=8080
Storage:

Channel type: channel

chat_id: -100387776503

Bot is admin of the channel with permission to post messages.

Worker:

Type: Telegram

TELEGRAM_BOT_TOKEN: same token that I use in manual Bot API tests below.

Attached to the storage above.

What works:

The bot token and chat_id are 100% correct.

Manual API calls with the same bot and chat_id work:

text
https://api.telegram.org/bot/getUpdates
https://api.telegram.org/bot/sendMessage?chat_id=-1003876731033&text=hello_from_api
https://api.telegram.org/bot/sendPhoto?chat_id=-1003876731033&photo=https://telegram.org/img/t_logo.png
All of these return ok: true, and I see messages/photos in the channel.

What fails:

When I upload any file via Pentaract UI (png/jpg/mp4, small size), UI shows Something went wrong, and container logs show:

text
2026-03-04T14:23:16.912880Z DEBUG pentaract::services::files: file loaded successfully
2026-03-04T14:23:16.915206Z ERROR pentaract::services::files: [Telegram API] 400 Bad Request
2026-03-04T14:23:16.917998Z ERROR pentaract::errors: [Telegram API] 400 Bad Request

2026-03-04T14:23:55.263898Z DEBUG pentaract::services::files: sending task to manager
2026-03-04T14:23:55.263973Z DEBUG pentaract::storage_manager: got msg
2026-03-04T14:23:55.695350Z DEBUG pentaract::services::files: file loaded successfully
2026-03-04T14:23:55.700195Z ERROR pentaract::services::files: [Telegram API] 400 Bad Request
2026-03-04T14:23:55.701857Z ERROR pentaract::errors: [Telegram API] 400 Bad Request
The pattern repeats for every uploaded file: file loaded successfully followed by [Telegram API] 400 Bad Request.

Observations / guesses:

Since manual sendMessage and sendPhoto with the same bot and chat_id work fine, this looks like an issue with how Pentaract builds the request to Telegram (method / payload / multipart fields).

The channel currently has has_protected_content: true in updates, but disabling content protection doesn’t change the behavior (manual API calls keep working; Pentaract still gets 400).

It would be very helpful to log the actual Telegram API method and error description from the response body (for example, description: "...") to see what exactly Telegram complains about.

Questions:

Which Telegram method is used internally for file uploads (sendDocument, sendPhoto, etc.)?

Is there any way to enable more verbose logging of the full Telegram API response (including description)?

Could this be related to channels with protected content or a specific Telegram API change?

If you need more details (full logs, compose file, etc.), I can provide them. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions