opendataloader-project/opendataloader-pdf · error · IOException
pdf2img RESULT is empty
Error message
pdf2img RESULT is empty
What it means
fetchPageImage parsed the response JSON but the top-level RESULT field is missing, not an array, or empty. The code navigates RESULT[0].RESULT.PAGE_PNG_DATA, so a missing/empty RESULT array means the backend did not return a page render. Per-page IOException, caught and logged by table/figure handlers.
Source
Thrown at java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HancomAIClient.java:700
.url(baseUrl + PDF2IMG_ENDPOINT)
.post(body)
.build();
try (Response response = httpClient.newCall(httpRequest).execute()) {
if (!response.isSuccessful()) {
throw new IOException("pdf2img returned HTTP " + response.code());
}
ResponseBody respBody = response.body();
if (respBody == null) {
throw new IOException("pdf2img returned empty body");
}
JsonNode root = objectMapper.readTree(respBody.string());
// Navigate: RESULT[0].RESULT.PAGE_PNG_DATA
JsonNode resultArr = root.get("RESULT");
if (resultArr == null || !resultArr.isArray() || resultArr.size() == 0) {
throw new IOException("pdf2img RESULT is empty");
}
JsonNode pageResult = resultArr.get(0);
JsonNode innerResult = pageResult.get("RESULT");
if (innerResult == null) {
throw new IOException("pdf2img inner RESULT is null");
}
String pngBase64 = innerResult.has("PAGE_PNG_DATA")
? innerResult.get("PAGE_PNG_DATA").asText() : null;
if (pngBase64 == null || pngBase64.isEmpty()) {
throw new IOException("pdf2img PAGE_PNG_DATA is empty");
}
byte[] pngBytes;
try {
pngBytes = Base64.getDecoder().decode(pngBase64);
} catch (IllegalArgumentException e) {View on GitHub (pinned to a7789b8e77)
Solutions
- Log the raw pdf2img response body to see the actual envelope (often a SUCCESS=false with MSG)
- Check the backend logs for the failing PAGE_INDEX
- Retry the page; if consistent, accept the per-page skip
- Align client and backend pdf2img contract versions
Defensive patterns
Strategy: try-catch
Try / catch
try {
return cache.getOrFetch(pageNum, idx -> client.fetchPageImage(pdf, idx, crop));
} catch (IOException e) {
if (e.getMessage().startsWith("pdf2img RESULT is empty")) {
log.warn("page {} produced no render result — backend may have rejected it", pageNum);
}
continue; // skip this page
} Prevention
- Log raw pdf2img bodies in staging to spot envelope changes
- Keep client and backend pdf2img versions aligned
- Accept per-page skips for degraded output
When it happens
Trigger: objectMapper.readTree(body) succeeds but root.get("RESULT") is null, not a JsonNode array, or has size 0.
Common situations: Backend returned SUCCESS=false but fetchPageImage still got 2xx with an error envelope lacking RESULT; version skew changing the pdf2img response shape; backend partial failure on the requested PAGE_INDEX.
Related errors
- pdf2img returned empty body
- pdf2img inner RESULT is null
- pdf2img PAGE_PNG_DATA is empty
- pdf2img PAGE_PNG_DATA is not valid Base64
- pdf2img returned HTTP %s
AI-assisted analysis of opendataloader-project/opendataloader-pdf@a7789b8e77 (2026-08-14).
Data as JSON: /api/errors/413c53aa4738ca1f.
Report an issue: GitHub.