{"record":{"id":"1dc3071b7aab28f5","repo":"odysseus-dev/odysseus","slug":"server-returned-res-status","errorCode":null,"errorMessage":"Server returned ${res.status}","messagePattern":"Server returned (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"static/js/editor/ai-tools-misc.js","lineNumber":125,"sourceCode":"    let upWp = null;\n    try {\n      upWp = spinnerModule.createWhirlpool(14);\n      upWp.element.style.cssText = 'display:inline-block;vertical-align:middle;position:relative;top:1px;margin-right:6px;width:14px;height:14px;';\n      btn.innerHTML = '';\n      btn.appendChild(upWp.element);\n      const lbl = document.createElement('span');\n      lbl.textContent = 'Upscaling…';\n      btn.appendChild(lbl);\n    } catch (_) { btn.textContent = 'Upscaling…'; }\n    try {\n      const flat = flatten();\n      const imageB64 = flat.toDataURL('image/png').split(',')[1];\n      const res = await fetch('/api/image/upscale-local', {\n        method: 'POST', credentials: 'same-origin',\n        headers: { 'Content-Type': 'application/json' },\n        body: JSON.stringify({ image: imageB64, scale: 2 }),\n      });\n      if (!res.ok) throw new Error('Server returned ' + res.status);\n      const data = await res.json();\n      if (data.image) {\n        const img = new Image();\n        img.onload = () => {\n          if (!state.editorOpen) return;\n          saveState();\n          const newW = img.width, newH = img.height;\n          const layer = createLayer('AI Upscaled', newW, newH);\n          layer.ctx.drawImage(img, 0, 0);\n          state.layers.push(layer);\n          state.activeLayerId = layer.id;\n          state.imgWidth = newW; state.imgHeight = newH;\n          state.mainCanvas.width = newW; state.mainCanvas.height = newH;\n          if (state.maskCanvas) { state.maskCanvas.width = newW; state.maskCanvas.height = newH; }\n          const sizeLabel = document.getElementById('ge-canvas-size');\n          if (sizeLabel) sizeLabel.textContent = `${newW}×${newH}`;\n          fitZoom();\n          composite();","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/static/js/editor/ai-tools-misc.js#L107-L143","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check the status code for /api/image/upscale-local in DevTools","404: update the backend to a build that implements the local upscale route","413/502 from a proxy: raise the body-size limit or downscale the canvas before upscaling","500: ensure the server's local upscale model/dependency is installed and check server logs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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); }","preventionTips":["Probe availability of local-model routes at editor open and disable the button if absent","Downscale large canvases before sending base64 payloads","Read the numeric status first: 404=missing route, 413=body limit, 500=model issue","Keep the spinner destroy in finally so the button always recovers"],"tags":["network","http","fetch","upscale","local-model","editor"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}