{"record":{"id":"038937d0623821bf","repo":"prestodb/presto","slug":"generic-internal-error-038937","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Failed to parse document source","messagePattern":"Failed to parse document source","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ScanQueryPageSource.java","lineNumber":211,"sourceCode":"    public void close()\n    {\n        iterator.close();\n    }\n\n    @Override\n    public Page getNextPage()\n    {\n        long size = 0;\n\n        while (size < PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES && iterator.hasNext()) {\n            Hit hit = iterator.next();\n            Map<String, Object> document;\n            try {\n                JsonData source = (JsonData) hit.source();\n                document = mapper.readValue(source.toJson().toString(), new TypeReference<>() {});\n            }\n            catch (IOException e) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Failed to parse document source\");\n            }\n\n            for (int i = 0; i < decoders.size(); i++) {\n                String field = columns.get(i).getName();\n                decoders.get(i).decode(hit, () -> getField(document, field), columnBuilders[i]);\n            }\n\n            if (hit.source() != null) {\n                try {\n                    String json = mapper.writeValueAsString(hit.source());\n                    totalBytes += json.getBytes(StandardCharsets.UTF_8).length;\n                }\n                catch (JsonProcessingException e) {\n                    throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Failed to serialize document source\");\n                }\n            }\n\n            completedPositions += 1;","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ScanQueryPageSource.java#L193-L229","documentation":"getNextPage wraps IOException from Jackson deserialization of an Elasticsearch hit's _source JSON into this PrestoException: a document in the index does not match the expected JSON structure and cannot be converted to the table schema.","triggerScenarios":"Thrown at presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ScanQueryPageSource.java:211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the index mapping and stored _source are valid JSON","Reindex documents with malformed sources","Verify field types in the index mapping match expectations"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}