odysseus-dev/odysseus · error · Error

Server returned ${res.status}

Error message

Server returned ${res.status}

What it means

Thrown when POST /api/image/upscale-local (local upscaler, no external provider) returns a non-2xx status. Message is 'Server returned <status>' with no body detail, so diagnosing requires the Network tab.

Source

Thrown at static/js/editor/ai-tools-misc.js:125

    let upWp = null;
    try {
      upWp = spinnerModule.createWhirlpool(14);
      upWp.element.style.cssText = 'display:inline-block;vertical-align:middle;position:relative;top:1px;margin-right:6px;width:14px;height:14px;';
      btn.innerHTML = '';
      btn.appendChild(upWp.element);
      const lbl = document.createElement('span');
      lbl.textContent = 'Upscaling…';
      btn.appendChild(lbl);
    } catch (_) { btn.textContent = 'Upscaling…'; }
    try {
      const flat = flatten();
      const imageB64 = flat.toDataURL('image/png').split(',')[1];
      const res = await fetch('/api/image/upscale-local', {
        method: 'POST', credentials: 'same-origin',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ image: imageB64, scale: 2 }),
      });
      if (!res.ok) throw new Error('Server returned ' + res.status);
      const data = await res.json();
      if (data.image) {
        const img = new Image();
        img.onload = () => {
          if (!state.editorOpen) return;
          saveState();
          const newW = img.width, newH = img.height;
          const layer = createLayer('AI Upscaled', newW, newH);
          layer.ctx.drawImage(img, 0, 0);
          state.layers.push(layer);
          state.activeLayerId = layer.id;
          state.imgWidth = newW; state.imgHeight = newH;
          state.mainCanvas.width = newW; state.mainCanvas.height = newH;
          if (state.maskCanvas) { state.maskCanvas.width = newW; state.maskCanvas.height = newH; }
          const sizeLabel = document.getElementById('ge-canvas-size');
          if (sizeLabel) sizeLabel.textContent = `${newW}×${newH}`;
          fitZoom();
          composite();

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Check the status code for /api/image/upscale-local in DevTools
  2. 404: update the backend to a build that implements the local upscale route
  3. 413/502 from a proxy: raise the body-size limit or downscale the canvas before upscaling
  4. 500: ensure the server's local upscale model/dependency is installed and check server logs
Defensive patterns

Strategy: try-catch

Try / catch

try { const res = await fetch('/api/image/upscale-local', {...}); if (!res.ok) { let m = 'Server returned ' + res.status; try { m = (await res.json()).detail || m; } catch {} throw new Error(m); } ... } catch (e) { uiModule.showToast('AI upscale failed: ' + e.message); }

Prevention

When it happens

Trigger: Clicking the Upscale (2x) button: server-side upscale dependency/model missing (500), request body with the flattened PNG too large (413), session expired (401), or the local-upscale route absent in an older backend build (404).

Common situations: Fresh server install without the local upscaler model downloaded; reverse proxy with a low client_max_body_size rejecting the multi-MB base64 image; backend/frontend version skew where the route was not yet implemented.

Related errors


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/1dc3071b7aab28f5. Report an issue: GitHub.