anomalyco / anomalyco/opencode

V2 media normalization double-prefixes uppercase DATA: URLs

Open
#47,538 0 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 5, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

While testing V2's OpenAI Chat request compilation, I found that an uppercase DATA: URL gets a second data-URL prefix:

Input:  DATA:image/png;base64,AAECAw==
Output: data:image/png;base64,DATA:image/png;base64,AAECAw==

Lowercase data: and raw base64 both work. Existing data URLs should be recognized regardless of scheme casing, as described in RFC 3986 §3.1.

The case-sensitive part.data.startsWith("data:") check in packages/ai/src/protocols/shared.ts sends the uppercase URL down the raw-base64 path.

I can contribute a focused fix and regression tests if this is not already being addressed.

Plugins

None; reproduced in the provider test harness.

OpenCode version

V2 source at 7a4ad68af6; Bun 1.4.2.

Steps to reproduce

In packages/ai/test/provider/openai-chat.test.ts, using the existing model, imports, and Effect test harness, compile:

const prepared = yield* compileRequest(
  LLM.request({
    model,
    messages: [
      Message.user({
        type: "media",
        mediaType: "image/png",
        data: "DATA:image/png;base64,AAECAw==",
      }),
    ],
  }),
)

The image URL in prepared.body.messages contains the double prefix shown above. Repeating with AAECAw== or data:image/png;base64,AAECAw== produces the expected URL.

This checks request encoding only: the bytes are a small test fixture, not a PNG, and no provider call is needed.

Operating System

macOS arm64.

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.