prestodb/presto · error · IllegalArgumentException

Unable to determine S3 bucket from URI.

Error message

Unable to determine S3 bucket from URI.

What it means

getBucketName works around URIs with hosts containing '_' (where java.net.URI returns a null host); when neither getHost() nor a UserInfo-free getAuthority() yields a bucket, the URI has no determinable S3 bucket and this is thrown.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1423

     * Helper function used to work around the fact that if you use an S3 bucket with an '_' that java.net.URI
     * behaves differently and sets the host value to null whereas S3 buckets without '_' have a properly
     * set host field. '_' is only allowed in S3 bucket names in us-east-1.
     *
     * @param uri The URI from which to extract a host value.
     * @return The host value where uri.getAuthority() is used when uri.getHost() returns null as long as no UserInfo is present.
     * @throws IllegalArgumentException If the bucket can not be determined from the URI.
     */
    public static String getBucketName(URI uri)
    {
        if (uri.getHost() != null) {
            return uri.getHost();
        }

        if (uri.getUserInfo() == null) {
            return uri.getAuthority();
        }

        throw new IllegalArgumentException("Unable to determine S3 bucket from URI.");
    }

    public static PrestoS3FileSystemStats getFileSystemStats()
    {
        return STATS;
    }

    public static RequestMetricCollector getMetricsCollector()
    {
        return metricCollector;
    }

    public static void setMetricsCollector(RequestMetricCollector customMetricCollector)
    {
        metricCollector = customMetricCollector;
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use the s3a:// path-style URI form with a supported bucket name
  2. Avoid underscores in bucket names (only valid in us-east-1)
  3. Encode the URI so the authority is parseable
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1423 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/4c2be57a0b2f9a0c. Report an issue: GitHub.