{"record":{"id":"0cb53ecf38189c3c","repo":"prestodb/presto","slug":"generic-internal-error-0cb53e","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"unsupported hash algorithm","messagePattern":"unsupported hash algorithm","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/PrestoSparkQueryExecutionFactory.java","lineNumber":594,"sourceCode":"            if (sqlFileSizeInBytes.isPresent()) {\n                if (Integer.valueOf(sqlFileSizeInBytes.get()) != sqlFileBytes.length) {\n                    throw new PrestoException(\n                            MALFORMED_QUERY_FILE,\n                            format(\"sql file size %s is different from expected sqlFileSizeInBytes %s\", sqlFileBytes.length, sqlFileSizeInBytes.get()));\n                }\n            }\n            if (sqlFileHexHash.isPresent()) {\n                try {\n                    MessageDigest md = MessageDigest.getInstance(\"SHA-512\");\n                    String actualHexHashCode = BaseEncoding.base16().lowerCase().encode(md.digest(sqlFileBytes));\n                    if (!sqlFileHexHash.get().equals(actualHexHashCode)) {\n                        throw new PrestoException(\n                                MALFORMED_QUERY_FILE,\n                                format(\"actual hash code %s is different from expected sqlFileHexHash %s\", actualHexHashCode, sqlFileHexHash.get()));\n                    }\n                }\n                catch (NoSuchAlgorithmException e) {\n                    throw new PrestoException(GENERIC_INTERNAL_ERROR, \"unsupported hash algorithm\", e);\n                }\n            }\n            sql = new String(sqlFileBytes, UTF_8);\n        }\n\n        log.info(\"Query: %s\", sql);\n\n        QueryStateTimer queryStateTimer = new QueryStateTimer(systemTicker());\n\n        queryStateTimer.beginPlanning();\n\n        QueryId queryId = queryIdGenerator.createNextQueryId();\n        log.info(\"Starting execution for presto query: %s\", queryId);\n        System.out.printf(\"Query id: %s\\n\", queryId);\n\n        sparkContext.conf().set(PRESTO_QUERY_ID_CONFIG, queryId.getId());\n\n        SessionContext sessionContext = PrestoSparkSessionContext.createFromSessionInfo(","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/PrestoSparkQueryExecutionFactory.java#L576-L612","documentation":"While verifying a SQL file's hex hash, the code requests the SHA-512 algorithm from MessageDigest. If the JVM's security providers cannot supply SHA-512 (essentially impossible on standard JDKs, but possible with restricted/custom JCE provider setups), the NoSuchAlgorithmException is wrapped in a PrestoException with GENERIC_INTERNAL_ERROR and the message 'unsupported hash algorithm'.","triggerScenarios":"create() is called with sqlFileHexHash present and MessageDigest.getInstance(\"SHA-512\") throws NoSuchAlgorithmException — only on JVMs whose provider list excludes SHA-512.","commonSituations":"Running Presto on Spark with a stripped-down or FIPS-restricted JCE configuration missing SHA-512; broken java.security provider registration.","solutions":["Run on a standard JDK/JRE where SHA-512 is provided by the default SunJCE/SUN providers","Fix java.security configuration so a provider offering SHA-512 is registered","Remove the SHA-512 restriction or switch the deployment's security providers; this is environmental, not a code fix"],"exampleFix":"// java.security: ensure a provider with SHA-512, e.g.\n// security.provider.1=sun.security.provider.Sun\nsecurity.provider.1=sun.security.provider.Sun","handlingStrategy":"try-catch","validationCode":"try {\n    MessageDigest.getInstance(\"SHA-512\");\n} catch (NoSuchAlgorithmException e) {\n    throw new IllegalStateException(\"JVM lacks SHA-512; fix java.security providers before running Presto Spark\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    QueryExecution qe = factory.create(queryExecutionConfig);\n} catch (PrestoException e) {\n    if (\"GENERIC_INTERNAL_ERROR\".equals(e.getErrorCode().getName())\n            && e.getMessage().contains(\"unsupported hash algorithm\")) {\n        throw new IllegalStateException(\"Environment problem: JVM security providers missing SHA-512\", e);\n    } else throw e;\n}","preventionTips":["Run Presto Spark on a standard JDK distribution","Avoid stripped/FIPS-restricted JCE setups that drop SHA-512 unless the algorithm is replaced","Smoke-test hash verification on the target JVM image in CI"],"tags":["presto-spark","jvm","crypto","integrity-check"],"backgroundTag":"unsupported-hash-algorithm","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"}