{"record":{"id":"fc2d4c73f95ba17d","repo":"prestodb/presto","slug":"prometheus-output-error","errorCode":"PROMETHEUS_OUTPUT_ERROR","errorMessage":"Unable to handle Prometheus result: ","messagePattern":"Unable to handle Prometheus result: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-prometheus/src/main/java/com/facebook/presto/plugin/prometheus/PrometheusRecordCursor.java","lineNumber":84,"sourceCode":"    public PrometheusRecordCursor(List<PrometheusColumnHandle> columnHandles, ByteSource byteSource)\n    {\n        this.columnHandles = columnHandles;\n\n        fieldToColumnIndex = new int[columnHandles.size()];\n        for (int i = 0; i < columnHandles.size(); i++) {\n            PrometheusColumnHandle columnHandle = columnHandles.get(i);\n            fieldToColumnIndex[i] = columnHandle.getOrdinalPosition();\n        }\n\n        try (CountingInputStream input = new CountingInputStream(byteSource.openStream())) {\n            metricsItr = prometheusResultsInStandardizedForm(new PrometheusQueryResponse(input).getResults()).iterator();\n            totalBytes = input.getCount();\n        }\n        catch (PrestoException ex) {\n            throw ex;\n        }\n        catch (IOException e) {\n            throw new PrestoException(PROMETHEUS_OUTPUT_ERROR, \"Unable to handle Prometheus result: \" + e.toString());\n        }\n    }\n\n    static Block getBlockFromMap(Type mapType, Map<?, ?> map)\n    {\n        // on functions like COUNT() the Type won't be a MapType\n        if (!(mapType instanceof MapType)) {\n            return null;\n        }\n        Type keyType = mapType.getTypeParameters().get(0);\n        Type valueType = mapType.getTypeParameters().get(1);\n\n        BlockBuilder mapBlockBuilder = mapType.createBlockBuilder(null, 1);\n        BlockBuilder builder = mapBlockBuilder.beginBlockEntry();\n\n        for (Map.Entry<?, ?> entry : map.entrySet()) {\n            writeObject(builder, keyType, entry.getKey());\n            writeObject(builder, valueType, entry.getValue());","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-prometheus/src/main/java/com/facebook/presto/plugin/prometheus/PrometheusRecordCursor.java#L66-L102","documentation":"Constructor guard in PrometheusRecordCursor: the split's response bytes could not be parsed into the standardized metrics iterator (invalid or empty Prometheus result payload, I/O problem opening the stream), so cursor construction aborts with 'Unable to handle Prometheus result: ...'.","triggerScenarios":"Thrown at presto-prometheus/src/main/java/com/facebook/presto/plugin/prometheus/PrometheusRecordCursor.java:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the query; the underlying Prometheus response may have been transient or empty","Verify the Prometheus server returns well-formed query_range results","Check network/proxy integrity between Presto and Prometheus"],"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"}