{"record":{"id":"41d42c946289cd82","repo":"Stirling-Tools/Stirling-PDF","slug":"the-server-processed-the-request-but-returned-no-f","errorCode":null,"errorMessage":"The server processed the request but returned no files.","messagePattern":"The server processed the request but returned no files\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/core/hooks/tools/shared/useToolOperation.ts","lineNumber":312,"sourceCode":"              );\n            } else if (\n              await zipFileService.isZipResponse(\n                responseBlob,\n                typeof contentTypeHeader === \"string\"\n                  ? contentTypeHeader\n                  : undefined,\n              )\n            ) {\n              processedFiles = await extractZipFiles(responseBlob);\n            } else {\n              const filename = `${config.filePrefix}${filesForAPI[0]?.name || \"document.pdf\"}`;\n              processedFiles = [\n                new File([responseBlob], filename, { type: \"application/pdf\" }),\n              ];\n            }\n\n            if (processedFiles.length === 0) {\n              throw new Error(\n                \"The server processed the request but returned no files.\",\n              );\n            }\n\n            // Assume all inputs succeeded together unless server provided an error earlier\n            successSourceIds = validFiles.map((f) => f.fileId);\n            break;\n          }\n\n          case ToolType.custom: {\n            actions.setStatus(\"Processing files...\");\n            const result = await config.customProcessor(params, filesForAPI);\n\n            processedFiles = result.files;\n            const consumedAllInputs = result.consumedAllInputs || false;\n\n            // If consumedAllInputs flag is set, mark all inputs as successful\n            // (used for operations that combine N inputs into fewer outputs)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/hooks/tools/shared/useToolOperation.ts#L294-L330","documentation":"Thrown by the multiFile-endpoint branch of useToolOperation after the response is parsed into processedFiles (via responseHandler, zip extraction, or single-file wrapping) and the result is an empty array. The server returned 2xx with a body, but that body yielded zero usable output files — treated as a protocol/empty-output failure.","triggerScenarios":"Backend returned 200 with an empty body or a zip containing zero entries; a tool-specific responseHandler returned [] due to an internal filter; zip extraction succeeded but produced no files; the response blob was 0 bytes.","commonSituations":"Endpoint bug returning empty content on success; a filter inside responseHandler dropping all outputs; an operation that legitimately produced nothing (e.g. split with an empty page range) not being validated up front.","solutions":["Inspect the raw responseBlob size and Content-Type for the failing call (log before the length check).","Validate inputs (page ranges, selected files) before the call so operations that would produce nothing are rejected up front.","If the backend legitimately returns empty for a no-op case, convert this to an onStatus warning instead of throwing.","Add backend-side guarantees that success responses always contain at least one file."],"exampleFix":"// before\nif (processedFiles.length === 0) {\n  throw new Error(\"The server processed the request but returned no files.\");\n}\n\n// after — include endpoint + size for diagnosis\nif (processedFiles.length === 0) {\n  throw new Error(`The server processed the request but returned no files (${config.endpoint}, ${responseBlob.size} bytes).`);\n}","handlingStrategy":"validation","validationCode":"// Validate inputs that could legitimately produce no output before the call\nif (operationType === \"split\" && isEmptyPageRange(params.pageRanges)) {\n  // reject up front with 'select at least one page'\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runOperation();\n} catch (e) {\n  if (e instanceof Error && e.message === \"The server processed the request but returned no files.\") {\n    // log responseBlob size/type, check backend for empty-body bug\n    toast.error(\"The operation produced no output. Try different settings.\");\n  } else throw e;\n}","preventionTips":["Validate inputs (page ranges, selected files) so no-op operations are rejected up front.","Inspect responseBlob size/Content-Type when this fires to classify the empty output.","Push the backend to guarantee at least one file on success."],"tags":["response-parsing","validation","multi-file","tool-operation"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}