{"record":{"id":"806d26940d5aa071","repo":"OtterMind/Chat2DB","slug":"the-response-content-type-contenttype-is-not-s","errorCode":null,"errorMessage":"The response content-type: ${contentType} is not support!","messagePattern":"The response content-type: (.+?) is not support!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"chat2db-community-client/src/components/SSERequest/sseHttpsRequest.ts","lineNumber":83,"sourceCode":"\n      const contentType = response.headers.get('content-type') || '';\n\n      const mimeType = contentType.split(';')[0].trim();\n      switch (mimeType) {\n        /** SSE */\n        case 'text/event-stream': {\n          await this.sseResponseHandler<Output>(response, callbacks, params);\n          break;\n        }\n\n        /** JSON */\n        case 'application/json': {\n          await this.jsonResponseHandler<Output>(response, callbacks, params);\n          break;\n        }\n\n        default: {\n          throw new Error(`The response content-type: ${contentType} is not support!`);\n        }\n      }\n    }, callbacks);\n  };\n\n  private customResponseHandler = async <Output = SSEOutput>(\n    response: Response,\n    callbacks?: SSERequestCallbacks<Output>,\n    transformStream?: SSEStreamProps<Output>['transformStream'],\n  ) => {\n    const chunks: Output[] = [];\n\n    for await (const chunk of sseStream({\n      readableStream: response.body!,\n      transformStream,\n    })) {\n      chunks.push(chunk);\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-client/src/components/SSERequest/sseHttpsRequest.ts#L65-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the actual Content-Type in network devtools to identify what the backend is returning.","If the backend legitimately returns a new content type, add a case to the switch in sseHttpsRequest.ts.","Verify the AI endpoint URL is correct and points to the streaming API, not a web page.","Handle this error in the catch and log contentType for diagnosis."],"exampleFix":"// before\nconst response = await sseFetch(baseURL, requestInit);\n// mimeType switch throws on unexpected type\n\n// after\ntry {\n  // ... create handler\n} catch (e) {\n  if (e instanceof Error && /content-type.*is not support/.test(e.message)) {\n    console.error('Unexpected AI content-type. Endpoint may be misconfigured.');\n    onError('AI endpoint returned an unsupported response format.');\n    return;\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isUnsupportedContentTypeError(e: unknown): e is Error {\n  return e instanceof Error && /content-type.*is not support/.test(e.message);\n}","tryCatchPattern":"try {\n  await httpsRequest.create(params, callbacks);\n} catch (e) {\n  if (isUnsupportedContentTypeError(e)) {\n    onError('AI endpoint returned an unsupported response format. Check the URL and backend.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Verify the AI endpoint returns text/event-stream or application/json.","Check for proxy/gateway interference that changes Content-Type.","Log the actual Content-Type header for diagnosis when this occurs."],"tags":["sse","ai","content-type","response-handling","frontend"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}