{"record":{"id":"a73fe29002f4551a","repo":"apache/beam","slug":"error-while-attempting-to-verify-existence-of-bucket-gs-s","errorCode":null,"errorMessage":"Error while attempting to verify existence of bucket gs://%s","messagePattern":"Error while attempting to verify existence of bucket gs://(.+?)","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":860,"sourceCode":"              if (errorExtractor.itemNotFound(e) || errorExtractor.accessDenied(e)) {\n                return false;\n              }\n              return RETRY_DETERMINER.shouldRetry(e);\n            }\n          },\n          IOException.class,\n          sleeper);\n    } catch (GoogleJsonResponseException e) {\n      if (errorExtractor.accessDenied(e)) {\n        throw new AccessDeniedException(path.toString(), null, e.getMessage());\n      }\n      if (errorExtractor.itemNotFound(e)) {\n        throw new FileNotFoundException(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 verify existence of bucket gs://%s\", path.getBucket()),\n          e);\n    }\n  }\n\n  @VisibleForTesting\n  void createBucket(String projectId, Bucket bucket, BackOff backoff, Sleeper sleeper)\n      throws IOException {\n    Storage.Buckets.Insert insertBucket = storageClient.buckets().insert(projectId, bucket);\n    insertBucket.setPredefinedAcl(\"projectPrivate\");\n    insertBucket.setPredefinedDefaultObjectAcl(\"projectPrivate\");\n\n    try {\n      ResilientOperation.retry(\n          insertBucket::execute,\n          backoff,\n          new RetryDeterminer<IOException>() {","sourceCodeStart":842,"sourceCodeEnd":878,"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#L842-L878","documentation":"GcsUtilV1.bucketExists (bucket verification) converts an InterruptedException during the GCS bucket get call into this IOException. A 404 is handled separately as FileNotFoundException (bucket not found), so this error means the existence check itself was interrupted. The thread's interrupt flag is restored before throwing.","triggerScenarios":"Calling bucketExists(gcsPath) (directly or via GCS utilities like makeGcsUtil) while the executing thread is interrupted, e.g. during pipeline shutdown or task cancellation.","commonSituations":"Pipelines being cancelled or drained while setup code verifies the staging bucket; executor shutdown interrupting worker threads mid-call.","solutions":["Avoid interrupting threads during pipeline setup/teardown, or verify the bucket earlier","Catch IOException and check getCause() instanceof InterruptedException to distinguish this case","Re-run the existence check on a non-interrupted thread if needed"],"exampleFix":"// before\nif (!gcsUtil.bucketExists(path)) { ... }\n// after\ntry {\n  if (!gcsUtil.bucketExists(path)) { ... }\n} catch (IOException e) {\n  if (e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt(); // preserve status, abort setup\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean isInterruption(IOException e) { return e.getCause() instanceof InterruptedException; }","tryCatchPattern":"try {\n  boolean exists = gcsUtil.bucketExists(path);\n} catch (IOException e) {\n  if (e.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); }\n  throw e;\n}","preventionTips":["Perform existence checks before cancellation-prone phases","Preserve the interrupt status when handling","Don't swallow InterruptedException in wrapper code"],"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"}