{"record":{"id":"0ac40ea19ae52347","repo":"prestodb/presto","slug":"format-format-args","errorCode":null,"errorMessage":"format(format, args)","messagePattern":"format\\(format, args\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/HttpRequestSessionContext.java","lineNumber":366,"sourceCode":"        }\n        return properties;\n    }\n\n    private static Map<String, String> parseCredentialProperty(Map<String, List<String>> headerMap, String headerName)\n    {\n        Map<String, String> properties = new HashMap<>();\n        for (String header : splitSessionHeader(headerMap.getOrDefault(headerName, emptyList()))) {\n            List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header);\n            assertRequest(nameValue.size() == 2, \"Invalid %s header\", headerName);\n            properties.put(nameValue.get(0), urlDecode(nameValue.get(1)));\n        }\n        return properties;\n    }\n\n    private static void assertRequest(boolean expression, String format, Object... args)\n    {\n        if (!expression) {\n            throw new IllegalStateException(format(format, args));\n        }\n    }\n\n    private static Map<String, String> parsePreparedStatementsHeaders(Map<String, List<String>> headerMap, SqlParserOptions sqlParserOptions)\n    {\n        ImmutableMap.Builder<String, String> preparedStatements = ImmutableMap.builder();\n        for (String header : splitSessionHeader(headerMap.getOrDefault(PRESTO_PREPARED_STATEMENT, emptyList()))) {\n            List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header);\n            assertRequest(nameValue.size() == 2, \"Invalid %s header\", PRESTO_PREPARED_STATEMENT);\n\n            String statementName;\n            String sqlString;\n            try {\n                statementName = urlDecode(nameValue.get(0));\n                sqlString = urlDecode(nameValue.get(1));\n            }\n            catch (IllegalArgumentException e) {\n                throw new IllegalArgumentException((format(\"Invalid %s header: %s\", PRESTO_PREPARED_STATEMENT, e.getMessage())));","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/HttpRequestSessionContext.java#L348-L384","documentation":"assertRequest is an internal precondition helper: it throws IllegalStateException(formatting the message) whenever an expected invariant about the incoming HTTP request headers fails. The error fires for any header shape the router's request-to-session mapping does not accept.","triggerScenarios":"Any call to assertRequest(expression=false) during HttpRequestSessionContext construction, e.g. malformed header entries discovered while parsing prepared statements, catalog/property name parts, or other structural invariants of X-Presto-* headers.","commonSituations":"Proxies or clients forwarding duplicated/corrupted Presto headers, older clients sending header formats the newer router rejects, manual curl reproduction with malformed headers.","solutions":["Read the formatted message to identify which header failed the assertion","Correct the offending X-Presto-* header on the client to match the expected name=value (or catalog.property=value) structure","Compare against a known-good request from a working client to see the expected header shape"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { new HttpRequestSessionContext(request, parserOptions); }\ncatch (IllegalStateException | IllegalArgumentException e) { log.warn(\"Rejected request: {}\", e.getMessage()); return Response.status(Response.Status.BAD_REQUEST).build(); }","preventionTips":["Keep X-Presto-* headers in the canonical format produced by the official client","Log the full incoming header set when debugging assertion failures","Test proxy/gateway configurations for header tampering"],"tags":["http-header","assertion","presto-router"],"backgroundTag":"malformed-request-header","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"}