{"record":{"id":"75853b2e5a8e611e","repo":"apache/beam","slug":"unable-create-default-bucket","errorCode":null,"errorMessage":"Unable create default bucket.","messagePattern":"Unable create default bucket\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcpOptions.java","lineNumber":493,"sourceCode":"      LOG.info(\"No tempLocation specified, attempting to use default bucket: {}\", bucketName);\n\n      // Disable soft delete policy for a bucket.\n      // Reference: https://cloud.google.com/storage/docs/soft-delete\n      SoftDeletePolicy softDeletePolicy = new SoftDeletePolicy().setRetentionDurationSeconds(0L);\n\n      Bucket bucket =\n          new Bucket()\n              .setName(bucketName)\n              .setLocation(region)\n              .setSoftDeletePolicy(softDeletePolicy);\n      // Always try to create the bucket before checking access, so that we do not\n      // race with other pipelines that may be attempting to do the same thing.\n      try {\n        gcsOptions.getGcsUtil().createBucket(gcsOptions.getProject(), bucket);\n      } catch (FileAlreadyExistsException e) {\n        LOG.debug(\"Bucket '{}'' already exists, verifying access.\", bucketName);\n      } catch (IOException e) {\n        throw new RuntimeException(\"Unable create default bucket.\", e);\n      }\n\n      // Once the bucket is expected to exist, verify that it is correctly owned\n      // by the project executing the job.\n      try {\n        long owner = gcsOptions.getGcsUtil().bucketOwner(GcsPath.fromComponents(bucketName, \"\"));\n        checkArgument(\n            owner == projectNumber,\n            \"Bucket owner does not match the project from --project:\" + \" %s vs. %s\",\n            owner,\n            projectNumber);\n      } catch (IOException e) {\n        throw new RuntimeException(\n            \"Unable to determine the owner of the default bucket at gs://\" + bucketName, e);\n      }\n      return \"gs://\" + bucketName + \"/temp/\";\n    }\n","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcpOptions.java#L475-L511","documentation":"GcpOptions.tryCreateDefaultBucketWithPrefix calls GcsUtil.createBucket; any IOException other than FileAlreadyExistsException is rethrown as RuntimeException 'Unable create default bucket.' Bucket creation for the auto-generated default temp bucket failed.","triggerScenarios":"getDefaultBucketName() infers no suitable bucket and attempts to create gs://<project>-<hash>; createBucket throws IOException due to invalid bucket name, storage.buckets.create permission denied, quota exceeded, or API/network failure.","commonSituations":"Service account lacking storage.buckets.create on the project; project at bucket quota; bucket name conflicts or naming constraints; GCS API disabled.","solutions":["Pre-create a bucket and pass it via --tempLocation so auto-creation is skipped","Grant roles/storage.admin (or storage.buckets.create) to the pipeline identity","Check bucket quota and naming rules for the generated name","Verify storage component is enabled and reachable"],"exampleFix":"// before\n// relying on auto-created default bucket\n// after\ngsutil mb gs://my-project-beam-bucket\n--tempLocation=gs://my-project-beam-bucket/temp/","handlingStrategy":"try-catch","validationCode":"// ensure bucket creation is permitted or skip auto-create\nboolean canCreate = gcpOptions.getProject() != null; // plus storage.buckets.create IAM\nString explicit = options.getTempLocation();\nif (explicit != null && explicit.startsWith(\"gs://\")) { /* auto-create will be skipped */ }","typeGuard":null,"tryCatchPattern":"try {\n  String b = gcpOptions.getDefaultBucketName();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Unable create default bucket\")) {\n    gcpOptions.setTempLocation(\"gs://precreated-bucket/temp/\");\n  } else throw e;\n}","preventionTips":["Pre-create a temp bucket and pass --tempLocation","Grant storage.buckets.create to the pipeline service account","Watch bucket quota for the project","Use a valid bucket-name-compatible project setup (names embed project id/hash)"],"tags":["gcp","gcs","permissions","storage","java"],"backgroundTag":"file-write-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}