pdf not readable by Z.AI/GLM 5.3 Flash through OpenCode · Issue #49028 · anomalyco/opencode · GitHub
Skip to content

pdf not readable by Z.AI/GLM 5.3 Flash through OpenCode #49028

Closed as not planned

Description

@JeffPsymot

Description

For the same PDF :

  • joined in a prompt to GLM 5.3 Flash on the web : no problem
  • joined in a prompt to GLM 5.3 Flash API through OpenCode 1.18.30, I get the message "Failed to parse the file. Please check its accessibility and format." (no problem if I join a PNG image);
  • same in OpenCode Web 1.18.30 : no problem

According to GLM analysis, that error happens with this PDF because it contains an image. I tested a PDF without image and it is accepted!

And GLM says : opencode retains failed attachments in the session history: once the is uploaded, all subsequent requests in the session fail, even with a valid file. That is why it never worked during initialization, whereas it did work in a fresh session. The skill wasn't the variable; the "poisoned" pdf was.

Once I got a message "Failed to parse..." then it is necessary to end the session as I always get the same message whatever the prompt

PDF Failed to parse.pdf
PDF Failed to parse - Libre office created.pdf

Finally what surprises me is that one pdf is correctly accepted by GLM API via OpenCode...

Plugins

No response

OpenCode version

1.18.30

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

LINUX MINT

Terminal

No response

Activity

  1. github-actions commented on Sep 14, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct from these, please add more context about the specific error path.

  2. JeffPsymot commented on Sep 14, 2026

    @JeffPsymot
    Author

    Open Code version 1.18.30
    System : Linux Mint

  3. jlinazasoro commented on Sep 15, 2026

    @jlinazasoro

    I reproduced this, and I believe the diagnosis in the description points at the wrong variable. It isn't about the PDF containing an image — it's the transport opencode uses.

    Both PDFs you attached contain zero embedded images (pdfimages -list returns 0 rows for each), and both still fail. Holding everything else constant and changing only the transport:

    Your attachment file_data (what opencode sends) file_id (upload first)
    PDF Failed to parse.pdf (Quartz/macOS, 0 images) 400 1210 200 — "Es un currículum vitae (CV) en francés…"
    PDF Failed to parse - Libre office created.pdf (LibreOffice 24.2, 0 images) 400 1210 200 — reads "Test d'un pdf produit par…"

    Same bytes, same API key, same model, same minute.

    Why. Z.AI's OpenAPI for POST /paas/v4/chat/completions (VisionMultimodalContentItem → File) documents three members of file, and attaches the supported-format list — "Supports formats such as pdf, txt, word, jsonl, xlsx, pptx" — only to file_url. file_id is documented as GLM-5.3-Flash-only. file_data declares no format list at all.

    @ai-sdk/openai-compatible hardcodes application/pdf → file_data:

    if (part.mediaType === "application/pdf") {
      return { type: "file", file: {
        filename: part.filename ?? "document.pdf",
        file_data: `data:application/pdf;base64,${convert(part.data)}` }}
    }

    That is the one PDF route Z.AI rejects. Upload endpoint is POST /paas/v4/files, multipart, purpose=user_data — note purpose=agent also returns 1210, so the purpose matters.

    Full transport matrix, spec citations, controls ruling out thinking / max_tokens / account / network, and a minimal key-free repro are in #49237. Same root cause as #48868, which shows this is not zai-specific: the identical file_data mapping also breaks the opencode-go / zen gateway, there with a 422.

    Two follow-ups on your report:

    Worth noting the diagnosis in the description was attributed to "GLM analysis" — asking the model to explain its own API error. That's how the image hypothesis got in; the attachments disprove it.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions