{"record":{"id":"6a05669e20551448","repo":"gildas-lormeau/SingleFile","slug":"error-response-status","errorCode":null,"errorMessage":"Error \" + response.status","messagePattern":"Error \" \\+ response\\.status","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/webdav/webdav.js","lineNumber":93,"sourceCode":"\tabort() {\n\t\tif (this.controller) {\n\t\t\tthis.controller.abort();\n\t\t}\n\t}\n}\n\nasync function upload(filename, content, options) {\n\tconst { authorization, filenameConflictAction, prompt, signal, preventRetry } = options;\n\tlet { url } = options;\n\ttry {\n\t\tif (filenameConflictAction == CONFLICT_ACTION_OVERWRITE) {\n\t\t\tlet response = await sendRequest(filename, PUT_METHOD, content);\n\t\t\tif (response.status == CREATED_STATUS) {\n\t\t\t\treturn response;\n\t\t\t} else if (response.status >= MIN_ERROR_STATUS) {\n\t\t\t\tresponse = await sendRequest(filename, DELETE_METHOD);\n\t\t\t\tif (response.status >= MIN_ERROR_STATUS) {\n\t\t\t\t\tthrow new Error(ERROR_PREFIX_MESSAGE + response.status);\n\t\t\t\t}\n\t\t\t\treturn await upload(filename, content, options);\n\t\t\t}\n\t\t} else {\n\t\t\tlet response = await sendRequest(filename, HEAD_METHOD);\n\t\t\tif (response.status == FOUND_STATUS) {\n\t\t\t\tif (filenameConflictAction == CONFLICT_ACTION_UNIQUIFY || (filenameConflictAction == CONFLICT_ACTION_PROMPT && !prompt)) {\n\t\t\t\t\tconst { filenameWithoutExtension, extension, indexFilename } = splitFilename(filename);\n\t\t\t\t\toptions.indexFilename = indexFilename + 1;\n\t\t\t\t\treturn await upload(getFilename(filenameWithoutExtension, extension), content, options);\n\t\t\t\t} else if (filenameConflictAction == CONFLICT_ACTION_PROMPT) {\n\t\t\t\t\tfilename = await prompt(filename);\n\t\t\t\t\treturn filename ? upload(filename, content, options) : response;\n\t\t\t\t} else if (filenameConflictAction == CONFLICT_ACTION_SKIP) {\n\t\t\t\t\treturn response;\n\t\t\t\t}\n\t\t\t} else if (response.status == NOT_FOUND_STATUS) {\n\t\t\t\tresponse = await sendRequest(filename, PUT_METHOD, content);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/lib/webdav/webdav.js#L75-L111","documentation":"upload() in the WebDAV client PUTs the file; if the PUT fails (status >= MIN_ERROR_STATUS) it attempts a DELETE to clean up the partial file, and if that DELETE also fails it throws ERROR_PREFIX_MESSAGE + response.status. So this error means both the upload and the cleanup failed, leaving the failure status of the DELETE in the message.","triggerScenarios":"PUT to the WebDAV server returns an error status (auth failure, quota exceeded, read-only share); the follow-up DELETE of the same filename also returns >= MIN_ERROR_STATUS (file locked, no delete permission, path doesn't exist).","commonSituations":"Wrong WebDAV credentials or expired session; server quota exceeded on PUT; the account lacks DELETE permission so cleanup fails too; Nextcloud/ownCloud sharing permission restrictions; proxy returning error statuses.","solutions":["Check the thrown status code: fix the underlying PUT failure (credentials, quota, permissions) first — the DELETE error is secondary","Verify the WebDAV account has both write (PUT) and delete (DELETE) privileges on the target collection","Confirm the server URL/path and that the target collection exists and is writable","If status indicates quota (507) or lock (423), free space or release locks before retrying"],"exampleFix":"// before\nthrow new Error(ERROR_PREFIX_MESSAGE + response.status);\n// after\nthrow new Error(`${ERROR_PREFIX_MESSAGE} DELETE failed with ${response.status} after failed PUT of ${filename}`);","handlingStrategy":"retry","validationCode":"if (!webdavUrl || !webdavUrl.startsWith(\"http\")) throw new Error(\"Invalid WebDAV URL\");\nconst probe = await sendRequest(\"\", \"PROPFIND\");\nif (probe.status === 401) throw new Error(\"WebDAV auth failed before upload\");","typeGuard":"function isServerError(status) { return typeof status === \"number\" && status >= 400; }","tryCatchPattern":"try {\n  await webdav.upload(filename, content, options);\n} catch (e) {\n  const status = parseStatusFromMessage(e.message);\n  if (status === 423) throw new Error(\"File locked on WebDAV server — release lock and retry\");\n  if (status === 507) throw new Error(\"WebDAV quota exceeded\");\n  if (status === 401 || status === 403) throw new Error(\"Check WebDAV credentials/permissions (PUT and DELETE)\");\n  throw e;\n}","preventionTips":["Probe the server with PROPFIND/OPTIONS before bulk uploads","Ensure the account has PUT and DELETE rights on the target path","Monitor quota on Nextcloud/ownCloud accounts","Treat cleanup-DELETE failures as a signal the original PUT error needs investigation"],"tags":["webdav","http","upload"],"backgroundTag":"http-error-response","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}