apache/flink · error · IllegalArgumentException

Object name in %s is invalid

Error message

Object name in %s is invalid

What it means

Thrown by BlobUtils.parseUri when a gs:// URI has a valid bucket (authority) but an empty or whitespace-only path component — there is no object name at all. It fires before the leading-slash strip, distinguishing it from the 'slash-only path' variant.

Source

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

    /**
     * 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
     * @return The temporary bucket name
     */
    public static String getTemporaryBucketName(
            GSBlobIdentifier finalBlobIdentifier, GSFileSystemOptions options) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Append a real object key: 'gs://my-bucket/part-0'
  2. Validate constructed URIs (scheme + authority + non-empty path) in tests for path-building code
  3. Trim and reject blank object names before calling GS APIs

Example fix

// before
String uri = "gs://" + bucket; // -> gs://bucket, no object

// after
String uri = "gs://" + bucket + "/" + objectName; // require objectName non-empty
Defensive patterns

Strategy: validation

Validate before calling

java.net.URI uri = java.net.URI.create(candidate);
String path = uri.getPath();
if (path == null || path.trim().isEmpty()) {
    throw new IllegalArgumentException("gs URI must include an object path: " + candidate);
}

Prevention

When it happens

Trigger: Passing 'gs://bucket' or 'gs://bucket/' — Java's URI.getPath() returns empty/blank for both, and this first object-name check rejects it. Common when code builds gs://bucket + an empty object suffix.

Common situations: Path.join-style helpers producing an empty last segment; config values ending at the bucket; trailing-slash-only URIs.

Related errors


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