{"record":{"id":"e08d540edebb17d0","repo":"apache/flink","slug":"object-name-in-s-is-invalid","errorCode":null,"errorMessage":"Object name in %s is invalid","messagePattern":"Object name in (.+?) is invalid","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-filesystems/flink-gs-fs-hadoop/src/main/java/org/apache/flink/fs/gs/utils/BlobUtils.java","lineNumber":57,"sourceCode":"    /**\n     * Parses a blob id from a Google storage uri, i.e. gs://bucket/foo/bar yields a blob with\n     * bucket name \"bucket\" and object name \"foo/bar\".\n     *\n     * @param uri The gs uri\n     * @return The blob id\n     */\n    public static GSBlobIdentifier parseUri(URI uri) {\n        Preconditions.checkArgument(\n                uri.getScheme().equals(GSFileSystemFactory.SCHEME),\n                String.format(\"URI scheme for %s must be %s\", uri, GSFileSystemFactory.SCHEME));\n\n        String finalBucketName = uri.getAuthority();\n        if (StringUtils.isNullOrWhitespaceOnly(finalBucketName)) {\n            throw new IllegalArgumentException(String.format(\"Bucket name in %s is invalid\", uri));\n        }\n        String path = uri.getPath();\n        if (StringUtils.isNullOrWhitespaceOnly(path)) {\n            throw new IllegalArgumentException(String.format(\"Object name in %s is invalid\", uri));\n        }\n        String finalObjectName = path.substring(1); // remove leading slash from path\n        if (StringUtils.isNullOrWhitespaceOnly(finalObjectName)) {\n            throw new IllegalArgumentException(String.format(\"Object name in %s is invalid\", uri));\n        }\n        return new GSBlobIdentifier(finalBucketName, finalObjectName);\n    }\n\n    /**\n     * Returns the temporary bucket name. If options specifies a temporary bucket name, we use that\n     * one; otherwise, we use the bucket name of the final blob.\n     *\n     * @param finalBlobIdentifier The final blob identifier\n     * @param options The file system options\n     * @return The temporary bucket name\n     */\n    public static String getTemporaryBucketName(\n            GSBlobIdentifier finalBlobIdentifier, GSFileSystemOptions options) {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-filesystems/flink-gs-fs-hadoop/src/main/java/org/apache/flink/fs/gs/utils/BlobUtils.java#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"Path.join-style helpers producing an empty last segment; config values ending at the bucket; trailing-slash-only URIs.","solutions":["Append a real object key: 'gs://my-bucket/part-0'","Validate constructed URIs (scheme + authority + non-empty path) in tests for path-building code","Trim and reject blank object names before calling GS APIs"],"exampleFix":"// before\nString uri = \"gs://\" + bucket; // -> gs://bucket, no object\n\n// after\nString uri = \"gs://\" + bucket + \"/\" + objectName; // require objectName non-empty","handlingStrategy":"validation","validationCode":"java.net.URI uri = java.net.URI.create(candidate);\nString path = uri.getPath();\nif (path == null || path.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"gs URI must include an object path: \" + candidate);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Require a non-empty object name in path-building helpers","Reject trailing-slash-only config values at load time","Add URI edge-case tests (empty path, slash-only) to path utilities"],"tags":["gcs","uri","validation"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}