Skip to content

[BUG]: … Incorrect Padding Error #126

Open

Description

@NitinGCJ

Sometimes the returned image is corrupted and gives 'Incorrect Padding' error while decoding from base64

Has anyone faced similar problem ?

Activity

  1. TimPietrusky commented on May 28, 2025

    @TimPietrusky
    Contributor

    @NitinGCJ i have never seen such an error. with the 5.1.0 release of this worker, we enabled debug logs directly from ComfyUI into the logs of the worker. could you please update your endpoint to use the latest version of the worker and then provide the logs in this issue when this problem occurs again?

  2. self-assigned this
    on May 28, 2025
  3. TimPietruskyRunPod commented on Jun 2, 2026

    @TimPietruskyRunPod
    Contributor

    "Incorrect padding" on base64 decode is almost always one of three things:

    1. Truncation on the wire — RunPod's `/run` has a 10 MB body limit and `/runsync` is 20 MB. If your image is large, the response is being cut and the trailing padding (`=`) bytes are missing. Switch to S3 mode (`BUCKET_ENDPOINT_URL=...`) to bypass this.
    2. Client-side string corruption — splitting the base64 across lines, replacing `+` with space (URL decoding), or chopping the trailing `=` characters all produce this error. Decode the exact string the API returned without any transformation.
    3. You're decoding the JSON value including the surrounding quotes — `base64.b64decode("iVBOR...")` is correct; `base64.b64decode('"iVBOR..."')` includes the quotes and fails. Common in shell pipelines.

    Could you share:

    • The first and last 50 characters of the base64 string that failed to decode
    • The image resolution and approximate file size
    • Whether you're using `/run` or `/runsync`

    If it's #1 (oversized payload) the right fix is BUCKET_ENDPOINT_URL — possibly with the upcoming BUCKET_PREFIX from PR #191. If you can confirm the payload size we'll know which.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions