sigoden/dufs · error · Error
Invalid status
Error message
Invalid status ${res.status} What it means
assertResOK is a shared helper in dufs's frontend that unwraps fetch responses: if the HTTP status is outside 200-299 it throws the response body text, falling back to 'Invalid status <code>'. It converts any failed server API call (directory listings, uploads, searches, mkdir, etc.) into a thrown Error so the UI code can handle it uniformly.
Solutions
- Read the thrown body text — it usually carries the server's precise reason
- Add correct Authorization (basic auth) headers or log in before the operation
- Check that the target path/file exists and permissions allow the operation
- For uploads/moves, pick a non-conflicting target name (409 means it exists)
- Check dufs server logs for the underlying 5xx cause
Example fix
// before
const res = await fetch(url);
await assertResOK(res);
// after
const res = await fetch(url, { headers: authHeaders() });
try {
await assertResOK(res);
} catch (msg) {
showToast(`Request failed (${res.status}): ${msg}`);
if (res.status === 401) promptLogin();
} Defensive patterns
Strategy: try-catch
Validate before calling
const res = await fetch(url, { headers });
if (!res.ok) console.warn("request will fail", res.status, await res.clone().text()); Type guard
function isOkStatus(status) { return status >= 200 && status < 300; } Try / catch
try {
const res = await fetch(url, { headers });
await assertResOK(res);
} catch (bodyText) {
console.error(`API error ${res.status}: ${bodyText}`);
if (res.status === 401) promptLogin();
else if (res.status === 409) alert("Target already exists");
} Prevention
- Always send auth headers for protected paths
- Check existence before mkdir/move/rename to avoid 409/404
- Surface the thrown body text to the user — it contains the server reason
- Log res.status alongside the message for debugging
When it happens
Trigger: Any frontend fetch() to the dufs REST API that returns a non-2xx status: 401/403 from missing or wrong Authorization on protected paths, 404 for deleted paths, 409 for existing entries on mkdir/move, 500 from server-side I/O failures.
Common situations: Edited files without authentication while the path is protected by --auth; uploading to a read-only share; renaming/moving onto an existing target; server disk errors; stale links after the directory tree changed.
Related errors
AI-assisted analysis of sigoden/dufs@fe7fd564f8 (2026-09-09).
Data as JSON: /api/errors/0f93d23a6e81ae9d.
Report an issue: GitHub.
Appendix: source
Thrown at assets/index.js:974
}
function formatPercent(percent) {
if (percent > 10) {
return percent.toFixed(1) + "%";
} else {
return percent.toFixed(2) + "%";
}
}
function encodedStr(rawStr) {
return rawStr.replace(/[\u00A0-\u9999<>\&]/g, function (i) {
return '&#' + i.charCodeAt(0) + ';';
});
}
async function assertResOK(res) {
if (!(res.status >= 200 && res.status < 300)) {
throw new Error(await res.text() || `Invalid status ${res.status}`);
}
}
function getEncoding(contentType) {
const charset = contentType?.split(";")[1];
if (/charset/i.test(charset)) {
let encoding = charset.split("=")[1];
if (encoding) {
return encoding.toLowerCase();
}
}
return 'utf-8';
}
// Parsing base64 strings with Unicode characters
function decodeBase64(base64String) {
const binString = atob(base64String);
const len = binString.length;View on GitHub (pinned to fe7fd564f8)