QuantumNous/new-api · error · Error
HTTP ${response.status}: ${response.statusText}
Error message
HTTP ${response.status}: ${response.statusText} What it means
Thrown by the Ollama model-pull dialog when the streaming response to its fetch is not ok or has no body. The request posts channel_id and model_name to a SSE endpoint with Accept: text/event-stream; any non-2xx status (or missing body) aborts before the reader loop starts, producing this HTTP status string.
Source
Thrown at web/src/features/channels/components/dialogs/ollama-models-dialog.tsx:264
try {
const authHeaders = await getFreshAuthHeaders()
const response = await fetch('/api/channel/ollama/pull/stream', {
method: 'POST',
credentials: 'include',
headers: {
...authHeaders,
Accept: 'text/event-stream',
},
body: JSON.stringify({
channel_id: channelId,
model_name: pullName.trim(),
}),
signal: controller.signal,
})
if (!response.ok || !response.body) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
}
const reader = response.body.getReader()
const decoder = new TextDecoder()
let buffer = ''
while (true) {
const { done, value } = await reader.read()
if (done) break
buffer += decoder.decode(value, { stream: true })
const lines = buffer.split('\n')
buffer = lines.pop() || ''
for (const line of lines) {
if (!line.startsWith('data: ')) continue
const eventData = line.slice(6)
if (!eventData) continueView on GitHub (pinned to e2c7aa7b10)
Solutions
- Match the status: 401/403 → re-login/fix channel key; 404 → wrong endpoint or model name; 502/504 → proxy timeout or Ollama host down
- Verify the Ollama server in the channel settings is reachable from the backend (curl the Ollama /api/tags from the backend host)
- Increase proxy read timeout / disable buffering for the SSE route if pulls are long
- Retry with the exact model tag from `ollama list` on the target host
Example fix
// before
if (!response.ok || !response.body) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
}
// after - include the response body message when present
if (!response.ok || !response.body) {
let detail = `${response.status}: ${response.statusText}`
try {
const body = await response.json()
if (body?.message) detail = `${detail} - ${body.message}`
} catch { /* body not JSON */ }
throw new Error(detail)
} Defensive patterns
Strategy: try-catch
Validate before calling
const name = pullName.trim()
if (!name) { toast.error(t('Model name is required')); return }
if (!channelId) { toast.error(t('Channel is not selected')); return } Try / catch
try {
const response = await fetch(url, { headers: { ...authHeaders, Accept: 'text/event-stream' }, body: JSON.stringify({ channel_id: channelId, model_name: name }), signal: controller.signal })
if (!response.ok || !response.body) {
let detail = `HTTP ${response.status}: ${response.statusText}`
try { const b = await response.json(); if (b?.message) detail += ` - ${b.message}` } catch {}
throw new Error(detail)
}
// reader loop
} catch (error) {
toast.error(error instanceof Error ? error.message : 'Pull failed')
} Prevention
- Trim and require a non-empty model name before opening the stream
- Abort the fetch via AbortController when the dialog closes to avoid orphan streams
- Configure the reverse proxy with SSE-friendly timeouts (proxy_read_timeout, no buffering)
When it happens
Trigger: Submitting a model pull where the backend returns 4xx/5xx: unknown channel_id, model_name blank after trim, upstream Ollama server unreachable, model not found in the registry, or the long-lived request being killed by a proxy (502/504).
Common situations: Ollama host in the channel config wrong or down; reverse proxy (nginx) buffering/timing out SSE; model name typo so the registry returns 404; admin session expired giving 401; channel key invalid giving 403.
Related errors
AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15).
Data as JSON: /api/errors/53a38350a7b6b422.
Report an issue: GitHub.