apache/beam · error · FileNotFoundException
The specified bucket does not exist: gs://
Error message
The specified bucket does not exist: gs://%s
What it means
GcsUtilV2.getBucket fetches a Bucket via the Storage client and throws FileNotFoundException when Storage.get(bucketName) returns null, meaning the bucket does not exist (or is invisible to the credentials). StorageExceptions are translated separately.
Solutions
- Verify the bucket: gsutil ls gs://<bucket> or check the Cloud Console.
- Confirm the bucket name in pipeline options (tempLocation, stagingLocation) is exact and lowercase.
- Ensure the credential's project can access the bucket; grant roles/storage.admin or objectViewer on it.
- Create the bucket if it was never provisioned (gsutil mb).
Example fix
// before
options.setTempLocation("gs://my-temp-bucket/path"); // typo'd bucket
// after: validate early
new GcsOptionsValidator()/* or */; // gcloud storage buckets describe gs://my-temp-bucket
options.setTempLocation("gs://correct-temp-bucket/path"); Defensive patterns
Strategy: validation
Validate before calling
// fail fast at job setup
String bucket = GcsPath.fromUri(options.getTempLocation()).getBucket();
if (!gcsUtil.bucketAccessible(bucket)) {
throw new IllegalArgumentException("Bucket missing or inaccessible: " + bucket);
} Try / catch
try {
Bucket b = gcsUtil.getBucket(path);
} catch (FileNotFoundException e) {
// create the bucket or correct the configured location before proceeding
} Prevention
- Validate tempLocation/stagingLocation buckets during option validation
- Keep bucket names in one config source, verified with gsutil ls
- Ensure the credential's project matches the bucket's project
When it happens
Trigger: Any call path through getBucket — bucketAccessible, verifyBucketAccessible, or bucket(path) — where the bucket name doesn't exist or the caller has no permission to see it (a 403 can surface as null in some configurations).
Common situations: Typo in the --gcsEndpoint / staging bucket / tempLocation bucket name; using a bucket in a different project than the credential; bucket deleted or renamed between job submission and execution; regional bucket name mismatches.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- BigQuery temp location expected a valid 'gs://' path, but…
- Encountered an error when retrieving a configuration
- Error completing file copies with retries, sample: from
- Error trying to delete
- Error when reading
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/a7e46b97bc3096aa.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilV2.java:440
rewriteHelper(srcPaths, dstPaths, false, MissingStrategy.FAIL_IF_MISSING, strategy);
}
public void move(
Iterable<GcsPath> srcPaths,
Iterable<GcsPath> dstPaths,
MissingStrategy srcMissing,
OverwriteStrategy dstOverwrite)
throws IOException {
rewriteHelper(srcPaths, dstPaths, true, srcMissing, dstOverwrite);
}
/** Get the {@link Bucket} from Cloud Storage path or propagates an exception. */
public Bucket getBucket(GcsPath path, BucketGetOption... options) throws IOException {
String bucketName = path.getBucket();
try {
Bucket bucket = storage.get(bucketName, options);
if (bucket == null) {
throw new FileNotFoundException(
String.format("The specified bucket does not exist: gs://%s", bucketName));
}
return bucket;
} catch (StorageException e) {
throw translateStorageException(bucketName, null, e);
}
}
/** Returns whether the GCS bucket exists and is accessible. */
public boolean bucketAccessible(GcsPath path) {
try {
// Fetch only the name field to minimize data transfer
getBucket(path, BucketGetOption.fields(BucketField.NAME));
return true;
} catch (IOException e) {
return false;
}
}View on GitHub (pinned to 12126d8942)