odysseus-dev/odysseus · error · Error

await res.text()

Error message

await res.text()

What it means

Thrown by _deleteFile in rag.js when DELETE /api/personal/file?filepath=... returns non-ok; the raw response text becomes the Error message. Because the body is not JSON-parsed, server detail strings or full HTML error pages can appear verbatim in the alert('Failed to delete file: ' + e.message).

Source

Thrown at static/js/rag.js:97

    });
  } catch (e) {
    console.error(e);
    box.innerHTML = '';
    const error = document.createElement('div');
    error.textContent = 'Failed to load files';
    error.style.color = 'var(--color-error)';
    box.appendChild(error);
  }
}

async function _deleteFile(filepath, displayName) {
  if (!await uiModule.styledConfirm(`Remove "${displayName}" from RAG?`, { confirmText: 'Remove', danger: true })) return;
  try {
    const res = await fetch(`${API_BASE}/api/personal/file?filepath=${encodeURIComponent(filepath)}`, {
      method: 'DELETE',
      credentials: 'same-origin'
    });
    if (!res.ok) throw new Error(await res.text());
    await loadPersonalDocs();
  } catch (e) {
    console.error('Delete failed:', e);
    alert('Failed to delete file: ' + e.message);
  }
}

/**
 * Upload files to RAG
 */
export async function uploadRagFiles(fileList) {
  if (!fileList || !fileList.length) return;

  const zone = document.getElementById('rag-upload-zone');
  if (zone) zone.textContent = 'Uploading…';

  const fd = new FormData();
  for (const file of fileList) {

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Refresh the personal docs list (loadPersonalDocs) and retry delete on the current entry.
  2. Check the response text shown in the alert — it names the server-side reason.
  3. If the store is mid-index, wait for ingestion to finish then delete.
  4. For stubborn entries, re-run the store's cleanup/reindex routine server-side.

Example fix

// before
if (!res.ok) throw new Error(await res.text());

// after
if (!res.ok) {
  const body = await res.json().catch(() => null);
  throw new Error(body?.detail || `HTTP ${res.status}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!filepath || filepath.includes('..')) { toast('Invalid file path'); return; }

Try / catch

try { if (!res.ok) { const b = await res.json().catch(() => null); throw new Error(b?.detail || `HTTP ${res.status}`); } await loadPersonalDocs(); } catch (e) { alert('Failed to delete file: ' + e.message); }

Prevention

When it happens

Trigger: Removing a RAG document whose file was already deleted from disk (404/500 with traceback text); filepath query param encoding a path outside the personal docs root being rejected; vector store still indexing the doc so delete is refused.

Common situations: Files removed manually on disk while indexed in the vector store; concurrent uploads/deletes racing; path traversal protection rejecting legitimately odd filenames.

Related errors


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