Skip to content

[Bug]: Image attachment media type is trusted as declared; PNG sent as image/jpeg makes every turn fail with 400 #44885

Done

Description

@epistex-dev

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Attach a PNG image to a thread under a JPEG type: either through MCP t3_thread_send / t3_thread_launch attachments with mimeType: "image/jpeg", or a pasted/uploaded image that gets stored with a .jpg name.
  2. Send the message on a Claude-backed provider (seen with a Pi provider instance using Claude Sonnet).

Expected behavior

The attachment is sent with its real media type (detected from the file signature), or rejected up front with a clear error.

Actual behavior

The file is stored as <id>.jpg while its bytes are PNG (89 50 4E 47), and it is forwarded as image/jpeg. Anthropic rejects the request:

400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.153.content.1.image.source.base64: The image was specified using the image/jpeg media type, but the image appears to be a image/png image"}}

The image stays in the thread history, so every later turn fails with the same 400 and the thread is stuck.

Two stored attachments on this machine have PNG bytes under a .jpg name: one from the MCP path (mcp-<uuid>.jpg, 2026-11-28) and one from the normal composer path (<uuid>.jpg, 2026-11-24), so the declared type seems to be trusted on both paths.

Impact

Blocks work completely

Version or commit

0.1.12 nightly 20261121.5038 (t3code-nightly-bin)

Environment

CachyOS Linux, desktop app, Wayland; provider: Pi coding agent instance, model Claude Sonnet via an Anthropic-compatible proxy.

Workaround

Correct the media type client-side before the request (we sniff the base64 prefix in a Pi extension), or start a new thread without the image.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions