{"record":{"id":"e8292fc25d516e12","repo":"opendataloader-project/opendataloader-pdf","slug":"pdf2img-returned-http-s","errorCode":null,"errorMessage":"pdf2img returned HTTP %s","messagePattern":"pdf2img returned HTTP (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HancomAIClient.java","lineNumber":688,"sourceCode":"    private BufferedImage fetchPageImage(byte[] pdfBytes, int pageIndex, CropOutput cropOutput)\n            throws IOException {\n        MultipartBody body = new MultipartBody.Builder()\n            .setType(MultipartBody.FORM)\n            .addFormDataPart(\"REQUEST_ID\",\n                \"odl-\" + sourcePdfShaShort + \"-pdf2img-p\" + pageIndex)\n            .addFormDataPart(\"PAGE_INDEX\", String.valueOf(pageIndex))\n            .addFormDataPart(\"FILE\", DEFAULT_FILENAME,\n                RequestBody.create(pdfBytes, MEDIA_TYPE_PDF))\n            .build();\n\n        Request httpRequest = new Request.Builder()\n            .url(baseUrl + PDF2IMG_ENDPOINT)\n            .post(body)\n            .build();\n\n        try (Response response = httpClient.newCall(httpRequest).execute()) {\n            if (!response.isSuccessful()) {\n                throw new IOException(\"pdf2img returned HTTP \" + response.code());\n            }\n\n            ResponseBody respBody = response.body();\n            if (respBody == null) {\n                throw new IOException(\"pdf2img returned empty body\");\n            }\n\n            JsonNode root = objectMapper.readTree(respBody.string());\n            // Navigate: RESULT[0].RESULT.PAGE_PNG_DATA\n            JsonNode resultArr = root.get(\"RESULT\");\n            if (resultArr == null || !resultArr.isArray() || resultArr.size() == 0) {\n                throw new IOException(\"pdf2img RESULT is empty\");\n            }\n\n            JsonNode pageResult = resultArr.get(0);\n            JsonNode innerResult = pageResult.get(\"RESULT\");\n            if (innerResult == null) {\n                throw new IOException(\"pdf2img inner RESULT is null\");","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HancomAIClient.java#L670-L706","documentation":"fetchPageImage posts the PDF page to the /support/pdf2img endpoint; a non-2xx status is converted to IOException. This is a per-page render error: callers (recognizeTableStructures, captionFigures) catch IOException and skip just that page with a WARNING, so it degrades rather than aborts the whole conversion unless it escapes.","triggerScenarios":"POST to baseUrl + '/support/pdf2img' with PAGE_INDEX and FILE returns a non-2xx HTTP code inside fetchPageImage's try-with-resources.","commonSituations":"pdf2img microservice down or misconfigured; page index out of range for the backend; backend cannot render a specific malformed page; backend resource limits hit on a large page.","solutions":["Check the backend pdf2img service logs for the failing page index","Confirm PAGE_INDEX is 0/1-based as the backend expects","Retry the page (the cache will re-fetch on next getOrFetch after the corrupt entry is cleared)","Accept the degraded result: affected tables/figures are skipped with a WARNING","Restart the backend pdf2img component if it crashed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before relying on page images, sanity-check page range against the PDF\nif (pageIndex < 0 || pageIndex >= pageCount) {\n    throw new IllegalArgumentException(\"page index out of range: \" + pageIndex);\n}","typeGuard":null,"tryCatchPattern":"// fetchPageImage is called via the cache; per-page handlers already catch:\ntry {\n    pageImage = cache.getOrFetch(pageNum, idx -> client.fetchPageImage(pdf, idx, crop));\n} catch (IOException e) {\n    log.warn(\"skipping page {}: {}\", pageNum, e.getMessage());\n    continue; // degrade gracefully, skip this page's tables/figures\n}","preventionTips":["Confirm PAGE_INDEX base (0 vs 1) matches the backend","Monitor backend pdf2img service health separately","Accept per-page skips as degraded-but-complete output rather than aborting"],"tags":["network","hybrid","hancom-ai","pdf2img","http-status"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}