{"record":{"id":"4c2be57a0b2f9a0c","repo":"prestodb/presto","slug":"unable-to-determine-s3-bucket-from-uri","errorCode":null,"errorMessage":"Unable to determine S3 bucket from URI.","messagePattern":"Unable to determine S3 bucket from URI\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java","lineNumber":1423,"sourceCode":"     * Helper function used to work around the fact that if you use an S3 bucket with an '_' that java.net.URI\n     * behaves differently and sets the host value to null whereas S3 buckets without '_' have a properly\n     * set host field. '_' is only allowed in S3 bucket names in us-east-1.\n     *\n     * @param uri The URI from which to extract a host value.\n     * @return The host value where uri.getAuthority() is used when uri.getHost() returns null as long as no UserInfo is present.\n     * @throws IllegalArgumentException If the bucket can not be determined from the URI.\n     */\n    public static String getBucketName(URI uri)\n    {\n        if (uri.getHost() != null) {\n            return uri.getHost();\n        }\n\n        if (uri.getUserInfo() == null) {\n            return uri.getAuthority();\n        }\n\n        throw new IllegalArgumentException(\"Unable to determine S3 bucket from URI.\");\n    }\n\n    public static PrestoS3FileSystemStats getFileSystemStats()\n    {\n        return STATS;\n    }\n\n    public static RequestMetricCollector getMetricsCollector()\n    {\n        return metricCollector;\n    }\n\n    public static void setMetricsCollector(RequestMetricCollector customMetricCollector)\n    {\n        metricCollector = customMetricCollector;\n    }\n}\n","sourceCodeStart":1405,"sourceCodeEnd":1441,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java#L1405-L1441","documentation":"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.","triggerScenarios":"Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1423 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the s3a:// path-style URI form with a supported bucket name","Avoid underscores in bucket names (only valid in us-east-1)","Encode the URI so the authority is parseable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}