prestodb/presto · error · PrestoException
GENERIC_INTERNAL_ERROR
GENERIC_INTERNAL_ERROR
Error message
unsupported hash algorithm
What it means
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'.
Source
Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/PrestoSparkQueryExecutionFactory.java:594
if (sqlFileSizeInBytes.isPresent()) {
if (Integer.valueOf(sqlFileSizeInBytes.get()) != sqlFileBytes.length) {
throw new PrestoException(
MALFORMED_QUERY_FILE,
format("sql file size %s is different from expected sqlFileSizeInBytes %s", sqlFileBytes.length, sqlFileSizeInBytes.get()));
}
}
if (sqlFileHexHash.isPresent()) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-512");
String actualHexHashCode = BaseEncoding.base16().lowerCase().encode(md.digest(sqlFileBytes));
if (!sqlFileHexHash.get().equals(actualHexHashCode)) {
throw new PrestoException(
MALFORMED_QUERY_FILE,
format("actual hash code %s is different from expected sqlFileHexHash %s", actualHexHashCode, sqlFileHexHash.get()));
}
}
catch (NoSuchAlgorithmException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "unsupported hash algorithm", e);
}
}
sql = new String(sqlFileBytes, UTF_8);
}
log.info("Query: %s", sql);
QueryStateTimer queryStateTimer = new QueryStateTimer(systemTicker());
queryStateTimer.beginPlanning();
QueryId queryId = queryIdGenerator.createNextQueryId();
log.info("Starting execution for presto query: %s", queryId);
System.out.printf("Query id: %s\n", queryId);
sparkContext.conf().set(PRESTO_QUERY_ID_CONFIG, queryId.getId());
SessionContext sessionContext = PrestoSparkSessionContext.createFromSessionInfo(View on GitHub (pinned to 55bb57d202)
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
Example fix
// java.security: ensure a provider with SHA-512, e.g. // security.provider.1=sun.security.provider.Sun security.provider.1=sun.security.provider.Sun
Defensive patterns
Strategy: try-catch
Validate before calling
try {
MessageDigest.getInstance("SHA-512");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("JVM lacks SHA-512; fix java.security providers before running Presto Spark");
} Try / catch
try {
QueryExecution qe = factory.create(queryExecutionConfig);
} catch (PrestoException e) {
if ("GENERIC_INTERNAL_ERROR".equals(e.getErrorCode().getName())
&& e.getMessage().contains("unsupported hash algorithm")) {
throw new IllegalStateException("Environment problem: JVM security providers missing SHA-512", e);
} else throw e;
} Prevention
- 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
When it happens
Trigger: create() is called with sqlFileHexHash present and MessageDigest.getInstance("SHA-512") throws NoSuchAlgorithmException — only on JVMs whose provider list excludes SHA-512.
Common situations: Running Presto on Spark with a stripped-down or FIPS-restricted JCE configuration missing SHA-512; broken java.security provider registration.
Related errors
- MALFORMED_QUERY_FILE
- Unexpected default trust managers:
- INVALID_SESSION_PROPERTY
- explain analyze is not supported
- INVALID_SESSION_PROPERTY
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/0cb53ecf38189c3c.
Report an issue: GitHub.