{"record":{"id":"728372fcced2b5fe","repo":"apache/beam","slug":"error-while-attempting-to-create-bucket-gs-s-for-project-s","errorCode":null,"errorMessage":"Error while attempting to create bucket gs://%s for project %s","messagePattern":"Error while attempting to create bucket gs://(.+?) for project (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilV1.java","lineNumber":900,"sourceCode":"                return false;\n              }\n              return RETRY_DETERMINER.shouldRetry(e);\n            }\n          },\n          IOException.class,\n          sleeper);\n      return;\n    } catch (GoogleJsonResponseException e) {\n      if (errorExtractor.accessDenied(e)) {\n        throw new AccessDeniedException(bucket.getName(), null, e.getMessage());\n      }\n      if (errorExtractor.itemAlreadyExists(e)) {\n        throw new FileAlreadyExistsException(bucket.getName(), null, e.getMessage());\n      }\n      throw e;\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new IOException(\n          String.format(\n              \"Error while attempting to create bucket gs://%s for project %s\",\n              bucket.getName(), projectId),\n          e);\n    }\n  }\n\n  @VisibleForTesting\n  void removeBucket(Bucket bucket, BackOff backoff, Sleeper sleeper) throws IOException {\n    Storage.Buckets.Delete getBucket = storageClient.buckets().delete(bucket.getName());\n\n    try {\n      ResilientOperation.retry(\n          getBucket::execute,\n          backoff,\n          new RetryDeterminer<IOException>() {\n            @Override\n            public boolean shouldRetry(IOException e) {","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilV1.java#L882-L918","documentation":"GcsUtilV1.createBucket converts an InterruptedException during the GCS bucket insert call into this IOException. A bucket-already-exists conflict is handled separately as FileAlreadyExistsException, so this error means bucket creation was interrupted rather than conflicting. The interrupt flag is restored before throwing.","triggerScenarios":"Calling createBucket(projectId, bucket) while the executing thread is interrupted, e.g. during pipeline cancellation or executor shutdown.","commonSituations":"Pipelines cancelled while creating a staging/temp bucket; test threads interrupted mid-setup.","solutions":["Ensure bucket creation happens before cancellation-prone phases, or pre-create the bucket out of band","Catch the IOException and check for InterruptedException cause to handle cancellation gracefully","Retry creation on a fresh, non-interrupted thread"],"exampleFix":"// before\ngcsUtil.createBucket(projectId, bucket);\n// after\ntry {\n  gcsUtil.createBucket(projectId, bucket);\n} catch (IOException e) {\n  if (e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt();\n    throw e; // treat as cancellation\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// create only if missing\nif (!gcsUtil.bucketExists(bucket)) { gcsUtil.createBucket(projectId, bucket); }","typeGuard":"boolean isInterruption(IOException e) { return e.getCause() instanceof InterruptedException; }","tryCatchPattern":"try {\n  gcsUtil.createBucket(projectId, bucket);\n} catch (FileAlreadyExistsException e) {\n  // tolerate pre-existing bucket\n} catch (IOException e) {\n  if (e.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); }\n  throw e;\n}","preventionTips":["Pre-create buckets via infrastructure tooling","Treat FileAlreadyExistsException as success in idempotent setup","Avoid creating buckets during shutdown"],"tags":["gcs","interrupted","concurrency"],"backgroundTag":"thread-interrupted","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}