Skip to content

SDK text/html guard misses responses with a charset parameter #41052

Description

@Mute-404

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.

Metadata

Metadata

Assignees

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