anomalyco / anomalyco/opencode

SDK text/html guard misses responses with a charset parameter

Open
#41,052 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 7, 2026.

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

Description

packages/sdk/js/src/v2/client.ts:86 checks the content-type with strict equality:

client.interceptors.response.use((response) => {
  const contentType = response.headers.get("content-type")
  if (contentType === "text/html")
    throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)")

  return response
})

Servers normally send text/html; charset=utf-8, so the comparison fails and the guard never fires. The caller then gets a JSON parse error instead of the message explaining that the server version doesn't support the request.

contentType?.startsWith("text/html") fixes it. Happy to send a PR.

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.