Plain source starting with `let ftype` is attached as video/mp4

Open Beginner friendly
#67,448 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #67449 by @qyb156 — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, typescript
Domain
backend

Research direction

Start in packages/core by reading the MIME detector imported as @opencode/core/mime; the issue reproduces the problem with Mime.detect(Buffer.from("let ftype = 1\n")). Check how it recognizes ISO-BMFF box types and compare the result with the same input using kind. Done when the JavaScript source is detected as text/plain while actual video files still identify correctly.

Written by the indexing model from the issue text.

Description

area/core platform/macos status/repro-simulated type/bug version/v2
Description

Attaching a JavaScript file whose first line is let ftype = "text/plain" labels the file as video/mp4. A session selecting a line from the file then retains the whole attachment. Request preparation for a text-only model replaces the attachment with “Cannot read … this model does not support video input.”

OpenCode version

Reproduced against dev at 484289a4e8. The MIME detector is identical in v2.4.3.

Steps to reproduce
  1. In a checkout of OpenCode, run bun install --frozen-lockfile and change to packages/core.
  2. Run bun -e 'import { Mime } from "@opencode/core/mime"; console.log(Mime.detect(Buffer.from("let ftype = 1\n")))' .
  3. The result is video/mp4. Changing ftype to kind returns the expected text/plain.

The four letters ftyp in the variable name land where an ISO-BMFF file would store its box type.

Operating System

macOS, arm64, Bun 1.4.4.

Dominant language
TypeScript
Stars
230k
Forks
31.3k
Avg merge
6h 58m
Merged PRs (30d)
471

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anomalyco/opencode

All issues in anomalyco/opencode

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.