OtterMind/Chat2DB · error · Error

The response content-type: ${contentType} is not support!

Error message

The response content-type: ${contentType} is not support!

What it means

HTTPSRequestClass.create throws when the response Content-Type MIME is neither text/event-stream nor application/json. The handler dispatches based on MIME type: SSE for streaming, JSON for single-shot responses. Any other content type (e.g., text/html from an error page, text/plain, or a misconfigured gateway) falls into the default case and throws.

Source

Thrown at chat2db-community-client/src/components/SSERequest/sseHttpsRequest.ts:83

      const contentType = response.headers.get('content-type') || '';

      const mimeType = contentType.split(';')[0].trim();
      switch (mimeType) {
        /** SSE */
        case 'text/event-stream': {
          await this.sseResponseHandler<Output>(response, callbacks, params);
          break;
        }

        /** JSON */
        case 'application/json': {
          await this.jsonResponseHandler<Output>(response, callbacks, params);
          break;
        }

        default: {
          throw new Error(`The response content-type: ${contentType} is not support!`);
        }
      }
    }, callbacks);
  };

  private customResponseHandler = async <Output = SSEOutput>(
    response: Response,
    callbacks?: SSERequestCallbacks<Output>,
    transformStream?: SSEStreamProps<Output>['transformStream'],
  ) => {
    const chunks: Output[] = [];

    for await (const chunk of sseStream({
      readableStream: response.body!,
      transformStream,
    })) {
      chunks.push(chunk);

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Check the actual Content-Type in network devtools to identify what the backend is returning.
  2. If the backend legitimately returns a new content type, add a case to the switch in sseHttpsRequest.ts.
  3. Verify the AI endpoint URL is correct and points to the streaming API, not a web page.
  4. Handle this error in the catch and log contentType for diagnosis.

Example fix

// before
const response = await sseFetch(baseURL, requestInit);
// mimeType switch throws on unexpected type

// after
try {
  // ... create handler
} catch (e) {
  if (e instanceof Error && /content-type.*is not support/.test(e.message)) {
    console.error('Unexpected AI content-type. Endpoint may be misconfigured.');
    onError('AI endpoint returned an unsupported response format.');
    return;
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Type guard

function isUnsupportedContentTypeError(e: unknown): e is Error {
  return e instanceof Error && /content-type.*is not support/.test(e.message);
}

Try / catch

try {
  await httpsRequest.create(params, callbacks);
} catch (e) {
  if (isUnsupportedContentTypeError(e)) {
    onError('AI endpoint returned an unsupported response format. Check the URL and backend.');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: The AI endpoint returns an HTML error page (text/html) instead of SSE/JSON. The Content-Type is text/plain. A charset suffix or unusual formatting causes split(';')[0].trim() to yield an unexpected value. A gateway returns application/xml.

Common situations: Reverse proxy returns a 502/503 HTML error page but sseFetch passes because status was masked. AI provider returns a content type the handler doesn't recognize. Backend misconfiguration sends text/plain for JSON errors.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/806d26940d5aa071. Report an issue: GitHub.