{"record":{"id":"54dc04f9b3fb21fa","repo":"Stirling-Tools/Stirling-PDF","slug":"pdf-conversion-result-did-not-include-page-data-p","errorCode":null,"errorMessage":"PDF conversion result did not include page data. Please update the server.","messagePattern":"PDF conversion result did not include page data\\. Please update the server\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/core/tools/pdfTextEditor/PdfTextEditor.tsx","lineNumber":793,"sourceCode":"                console.log(\"Job completed, retrieving JSON result...\");\n                jobComplete = true;\n\n                const resultResponse = await apiClient.get(\n                  `/api/v1/general/job/${jobId}/result`,\n                  {\n                    responseType: \"blob\",\n                  },\n                );\n\n                const jsonText = await resultResponse.data.text();\n                const result = JSON.parse(jsonText);\n\n                if (!Array.isArray(result.pages)) {\n                  console.error(\n                    \"Conversion result missing page array:\",\n                    result,\n                  );\n                  throw new Error(\n                    \"PDF conversion result did not include page data. Please update the server.\",\n                  );\n                }\n\n                const docResult = result as PdfJsonDocument;\n                parsed = {\n                  ...docResult,\n                  pages: docResult.pages ?? [],\n                };\n                shouldUseLazyMode = Boolean(docResult.lazyImages);\n                pendingJobId = shouldUseLazyMode ? jobId : null;\n                setConversionProgress(null);\n              } else {\n                console.log(\"Job not complete yet, continuing to poll...\");\n              }\n            } catch (pollError) {\n              console.error(\"Error polling job status:\", pollError);\n              const status = isAxiosError(pollError)","sourceCodeStart":775,"sourceCodeEnd":811,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/tools/pdfTextEditor/PdfTextEditor.tsx#L775-L811","documentation":"Thrown after successful job completion and result retrieval when the JSON result does not contain a pages array (Array.isArray(result.pages) is false). The conversion pipeline is expected to return { pages: [...], ... } — a missing pages array means the server returned a different schema, indicating a version mismatch between client and server.","triggerScenarios":"The server is running an older or newer version that produces a different JSON structure. The conversion endpoint returned a partial or error result that parsed as valid JSON but lacks the pages field. A server-side bug in the serialization pipeline.","commonSituations":"Client upgraded but server wasn't updated (or vice versa). Server running a forked or custom build with a different output schema. Conversion produced an empty result that was serialized without the pages key.","solutions":["Update the server to match the client's expected schema version.","Add backward-compatible parsing: check for alternative field names (e.g., result.data.pages, result.result.pages).","Log the full result object to diagnose the schema mismatch.","Add a version check at app startup and warn if server/client versions are incompatible."],"exampleFix":"// before\nif (!Array.isArray(result.pages)) {\n  throw new Error(\"PDF conversion result did not include page data. Please update the server.\");\n}\n\n// after\nconst pages = result.pages ?? result.data?.pages ?? result.result?.pages;\nif (!Array.isArray(pages)) {\n  console.error(\"Unexpected result schema:\", Object.keys(result));\n  throw new Error(\"PDF conversion result did not include page data. Please update the server.\");\n}","handlingStrategy":"type-guard","validationCode":"// Validate the result schema before using it\nconst pages = result.pages ?? result.data?.pages ?? result.result?.pages;\nif (!Array.isArray(pages)) {\n  throw new Error('Conversion result schema mismatch — check server version compatibility.');\n}","typeGuard":"function hasPagesArray(result: unknown): result is { pages: unknown[] } {\n  return typeof result === 'object' && result !== null && Array.isArray((result as any).pages);\n}","tryCatchPattern":"try {\n  const result = JSON.parse(jsonText);\n  if (!hasPagesArray(result)) {\n    throw new Error('Server returned incompatible result format.');\n  }\n} catch (error) {\n  setErrorMessage('Conversion result format is incompatible. Please update the server.');\n}","preventionTips":["Keep client and server versions in sync — schema changes require coordinated deployment.","Add a server version check at app startup and warn on mismatch.","Support multiple result schema versions with backward-compatible parsing.","Log the full result keys when the pages array is missing to diagnose schema drift."],"tags":["pdf-text-editor","schema","version-mismatch","conversion","json-parsing"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}