Skip to content

[Bug] Files with .odt extension are silently corrupted on download — binary file transcoded as UTF-8 text #1256

Closed as not planned

Description

@vadimrm

Summary

Any .odt file (OpenDocument Text) that an agent creates in Z.ai web chat arrives corrupted when the user downloads it: the file grows in size and is no longer a valid ZIP/ODF container. Byte-level forensics prove the download pipeline treated this binary file as UTF-8 text and replaced every invalid byte with U+FFFD (REPLACEMENT CHARACTER).

Other binary formats — .docx, .pdf, .zip — download byte-identical and are not affected.

Environment

  • Client: Z.ai web chat (browser), Windows 10
  • Date observed: 2026-10-27
  • Affected file type: .odt (MIME application/vnd.oasis.opendocument.text)

Steps to reproduce

  1. Ask the agent to create any .odt file (e.g. "generate a report as .odt") and download it from the chat.
  2. Compare the downloaded file with the original produced by the agent (size / md5).
  3. Try to open it in LibreOffice / OpenOffice — it fails; unzip -t reports a broken archive ("Bad offset for central directory").

Expected result

The downloaded file is byte-identical to the original. ODT is a ZIP container and must be transferred as binary.

Actual result

The file is silently corrupted in transit:

size md5
original .odt 185,719 bytes 71771e201df2e9abf3a9cae9abe9fdda
downloaded .odt 338,142 bytes acc0529218b9684158bb273507027799

Forensic evidence

Byte-level comparison of the downloaded copy identifies the exact transformation:

downloaded == original_bytes.decode('utf-8', errors='replace').encode('utf-8')
  • The equality is exact (same md5), so the transport ran the binary through a UTF-8 text transcoding path.
  • 77,573 bytes were invalid UTF-8 and were each replaced with U+FFFD (EF BF BD), inflating the file by ~82% and destroying the ZIP structure.
  • The same .odt packed inside a .zip attachment arrives byte-identical — the file itself is valid; only the loose-.odt download path is broken.

Probable root cause

The MIME type application/vnd.oasis.opendocument.text contains the substring text, so the transport likely classifies .odt as a text file and applies text processing. Consistent with this: .docx (application/vnd.openxmlformats-officedocument.wordprocessingml.document) and .pdf (application/pdf) do not contain text in their MIME type and pass through unchanged.

Suggested fix

Treat attachments as opaque binary by default. If a text-detection heuristic is needed, restrict it to text/* plus a whitelist of known text formats (.txt, .md, .csv, .json, …) — and explicitly exclude binary container types such as application/vnd.oasis.opendocument.*. Never apply errors='replace' transcoding to file downloads.

Workaround for users

Pack .odt (and any binary file) into a .zip wrapper — zip attachments survive the transfer untouched.

Impact

Silent data corruption: the file looks normal in the chat UI, but the downloaded copy is unusable. Users who don't verify checksums lose their documents without noticing.

Suggested labels: type: Bug · category: file operations · severity: affects experience

Activity

  1. github-actions commented on Oct 27, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
  2. vadimrm commented on Oct 27, 2026

    @vadimrm
    Author

    Accidental duplicate: my automation retried the issue-creation API call, although the first call had already succeeded (this issue was created twice, moments apart). The original issue is #1255 — please continue the discussion there. Closing this one. Sorry for the noise.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions