apache/flink · error · IllegalArgumentException

Bucket name in %s is invalid

Error message

Bucket name in %s is invalid

What it means

Thrown by BlobUtils.parseUri when a gs:// URI has no authority, i.e. no bucket name. The scheme is checked first, then the authority is validated; a null/whitespace authority means the URI cannot identify a blob and parsing aborts with IllegalArgumentException.

Source

Thrown at flink-filesystems/flink-gs-fs-hadoop/src/main/java/org/apache/flink/fs/gs/utils/BlobUtils.java:53

    /** The maximum number of blobs that can be composed in a single operation. */
    public static final int COMPOSE_MAX_BLOBS = 32;

    /**
     * Parses a blob id from a Google storage uri, i.e. gs://bucket/foo/bar yields a blob with
     * bucket name "bucket" and object name "foo/bar".
     *
     * @param uri The gs uri
     * @return The blob id
     */
    public static GSBlobIdentifier parseUri(URI uri) {
        Preconditions.checkArgument(
                uri.getScheme().equals(GSFileSystemFactory.SCHEME),
                String.format("URI scheme for %s must be %s", uri, GSFileSystemFactory.SCHEME));

        String finalBucketName = uri.getAuthority();
        if (StringUtils.isNullOrWhitespaceOnly(finalBucketName)) {
            throw new IllegalArgumentException(String.format("Bucket name in %s is invalid", uri));
        }
        String path = uri.getPath();
        if (StringUtils.isNullOrWhitespaceOnly(path)) {
            throw new IllegalArgumentException(String.format("Object name in %s is invalid", uri));
        }
        String finalObjectName = path.substring(1); // remove leading slash from path
        if (StringUtils.isNullOrWhitespaceOnly(finalObjectName)) {
            throw new IllegalArgumentException(String.format("Object name in %s is invalid", uri));
        }
        return new GSBlobIdentifier(finalBucketName, finalObjectName);
    }

    /**
     * Returns the temporary bucket name. If options specifies a temporary bucket name, we use that
     * one; otherwise, we use the bucket name of the final blob.
     *
     * @param finalBlobIdentifier The final blob identifier
     * @param options The file system options

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Fix the URI to include the bucket: 'gs://my-bucket/path/object'
  2. Check the config value for sinks/checkpoints ('s3://'-style keys like state.checkpoints.dir) for a missing bucket segment
  3. Log the constructed URI before use when paths are assembled dynamically

Example fix

// before
String uri = "gs:///" + objectName; // bucket omitted

// after
String uri = String.format("gs://%s/%s", bucketName, objectName);
Defensive patterns

Strategy: validation

Validate before calling

java.net.URI uri = java.net.URI.create(candidate);
if (uri.getAuthority() == null || uri.getAuthority().trim().isEmpty()) {
    throw new IllegalArgumentException("gs URI must include a bucket: " + candidate);
}

Prevention

When it happens

Trigger: Passing a URI like 'gs:///path/object' (three slashes, empty bucket) to GSFileSystem/GSBlobStorage operations — typically from string-concatenated paths or Path.toUri round-trips on malformed inputs.

Common situations: Building paths with 'gs://' + variable where the bucket variable is empty; misconfigured checkpoint/savepoint/output dir keys in flink-conf.yaml.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/3efe02d56d5df358. Report an issue: GitHub.