{"record":{"id":"bcdf992e54251630","repo":"odysseus-dev/odysseus","slug":"err-res-statustext","errorCode":null,"errorMessage":"err || res.statusText","messagePattern":"err \\|\\| res\\.statusText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"static/js/document.js","lineNumber":708,"sourceCode":"          <span id=\"pdf-export-status\" style=\"font-size:0.75rem;opacity:0.7;margin-right:auto;\"></span>\n          <button id=\"pdf-export-cancel\" class=\"confirm-btn confirm-btn-secondary\">Cancel</button>\n          <button id=\"pdf-export-download\" class=\"confirm-btn confirm-btn-primary\" disabled>Download PDF</button>\n        </div>\n      </div>\n    `;\n    document.body.appendChild(overlay);\n\n    const close = () => overlay.remove();\n    overlay.addEventListener('click', (e) => { if (e.target === overlay) close(); });\n    overlay.querySelector('#pdf-export-close').addEventListener('click', close);\n    overlay.querySelector('#pdf-export-cancel').addEventListener('click', close);\n\n    let fields = [];\n    try {\n      const res = await fetch(`${API_BASE}/api/document/${activeDocId}/export-pdf/preview`, { method: 'POST' });\n      if (!res.ok) {\n        const err = await res.text();\n        throw new Error(err || res.statusText);\n      }\n      const data = await res.json();\n      fields = data.fields || [];\n\n      const filledNow = data.filled || 0;\n      const total = data.total || fields.length;\n      overlay.querySelector('#pdf-export-summary').textContent =\n        `${filledNow} of ${total} fields filled. Review and adjust below before downloading.`;\n\n      const body = overlay.querySelector('#pdf-export-body');\n      body.innerHTML = '';\n\n      // Group by page\n      const byPage = new Map();\n      for (const f of fields) {\n        const p = f.page || 1;\n        if (!byPage.has(p)) byPage.set(p, []);\n        byPage.get(p).push(f);","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/static/js/document.js#L690-L726","documentation":"Error thrown when the export-preview POST /api/document/{id}/export-pdf/preview answers non-OK while building the field-review overlay. The raw body text (or statusText) becomes the message. The overlay is already on screen, so the error surfaces inside/around it.","triggerScenarios":"POST export-pdf/preview returns 404 (docId unknown), 422 (no PDF backing the doc), 500 (field extraction crash — PDF has no AcroForm, damaged xref), or HTML from an intermediary.","commonSituations":"Same as export: markdown-origin docs have no previewable form fields; encrypted or non-form PDFs break field extraction; backend PDF library version change altering extraction behavior; stale docId.","solutions":["Read the message body text — it is the backend's literal response","Ensure the doc was imported from a PDF that contains form fields","Retry after reloading the document list to refresh activeDocId","Check server logs around the preview call for the extraction exception"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!activeDocId || !docs.get(activeDocId)) { close(); uiModule?.showError?.('Document no longer available'); return; }","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(`${API_BASE}/api/document/${activeDocId}/export-pdf/preview`, { method: 'POST' });\n  if (!res.ok) {\n    const err = await res.text().catch(() => '');\n    let msg = err;\n    try { msg = JSON.parse(err).detail || err; } catch {}\n    throw new Error(msg || res.statusText || `HTTP ${res.status}`);\n  }\n  const data = await res.json();\n  fields = data.fields || [];\n} catch (e) {\n  overlay.querySelector('#pdf-export-summary').textContent = 'Preview failed: ' + e.message;\n}","preventionTips":["Give the overlay an inline error region so failures don't strand a blank modal","Close the overlay on 404/422 — those are unrecoverable for this doc","Parse detail from JSON bodies before falling back to raw text"],"tags":["fetch","http-error","pdf-export","preview","document"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}