zed-industries/zed · error

Unexpected content type

Error message

Unexpected content type: {:?}

What it means

send_message inspects the HTTP response Content-Type when the context server answers a POST; anything other than application/json (handled above) or text/event-stream (SSE) hits this guard, meaning the streamable-HTTP server replied with an unexpected media type.

Solutions

  1. Verify the context server responds with application/json or text/event-stream
  2. Check for a proxy or misconfiguration altering response content types
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/context_server/src/transport/http.rs:248 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/4ffe5db2bba70539. Report an issue: GitHub.

Appendix: source

Thrown at crates/context_server/src/transport/http.rs:248

                        // Only send non-empty responses
                        if !body.is_empty() {
                            self.response_tx
                                .send(body)
                                .await
                                .map_err(|_| anyhow!("Failed to send JSON response"))?;
                        }
                    }
                    Some(ct) if ct.starts_with(EVENT_STREAM_MIME_TYPE) => {
                        // SSE stream - set up streaming
                        self.setup_sse_stream(response).await?;
                    }
                    _ => {
                        // For notifications, 202 Accepted with no content type is ok
                        if is_notification && status.as_u16() == 202 {
                            log::debug!("Notification accepted");
                        } else {
                            return Err(anyhow!("Unexpected content type: {:?}", content_type));
                        }
                    }
                }
            }
            status if status.as_u16() == 202 => {
                // Accepted - notification acknowledged, no response needed
                log::debug!("Notification accepted");
            }
            _ => {
                let mut error_body = String::new();
                futures::AsyncReadExt::read_to_string(response.body_mut(), &mut error_body).await?;

                self.error_tx
                    .send(format!("HTTP {}: {}", response.status(), error_body))
                    .await
                    .map_err(|_| anyhow!("Failed to send error"))?;
            }
        }

View on GitHub (pinned to f4178619ac)