DuckDB failed to download extension "httpfs"
TL;DR
DuckDB could not connect to DuckDB's download extensions web.
Description
The error message
java.util.concurrent.CompletionException: java.lang.RuntimeException: java.sql.SQLException: java.sql.SQLException: Extension Autoloading Error: An error occurred while trying to automatically install the required extension 'httpfs':
Failed to download extension "httpfs" at URL "http://extensions.duckdb.org/v1.0.0/linux_amd64_gcc4/httpfs.duckdb_extension.gz"
Extension "httpfs" is an existing extension.
(ERROR Connection)
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.sql.SQLException: Extension Autoloading Error: An error occurred while trying to automatically install the required extension 'httpfs':
Failed to download extension "httpfs" at URL "http://extensions.duckdb.org/v1.0.0/linux_amd64_gcc4/httpfs.duckdb_extension.gz"
Extension "httpfs" is an existing extension.
(ERROR Connection)
at org.duckdb.DuckDBNative.duckdb_jdbc_prepare(Native Method)
at org.duckdb.DuckDBPreparedStatement.prepare(DuckDBPreparedStatement.java:116)
... 17 more
We traced the source code of DuckDB. We found the Failed to download extension is where.
https://github.com/duckdb/duckdb/blob/709a18da59afd565dc73e62cbfe901634a6c3100/src/main/extension/extension_install.cpp#L415-L425
Above the code, we can see the break when the request status is 200. On the contrary, DuckDB downloads the extension failed, so we can see the error message.
The message Extension "httpfs" is an existing extension is a mistake from DuckDB. They prepare the message only by taking the default extension list(internal_extensions) to check the extension will be installed is in the list. But actually, DuckDB does not install httpfs by default.