{"record":{"id":"4fe9b02b37ff3316","repo":"apache/hadoop","slug":"bucket-not-found-s","errorCode":null,"errorMessage":"Bucket not found: %s","messagePattern":"Bucket not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleCloudStorage.java","lineNumber":827,"sourceCode":"    if (sourceToDestinationObjectsMap.isEmpty()) {\n      return;\n    }\n\n    Map<StorageResourceId, GoogleCloudStorageItemInfo> bucketInfoCache = new HashMap<>();\n\n    for (Map.Entry<StorageResourceId, StorageResourceId> entry :\n        sourceToDestinationObjectsMap.entrySet()) {\n      StorageResourceId source = entry.getKey();\n      StorageResourceId destination = entry.getValue();\n      String srcBucketName = source.getBucketName();\n      String dstBucketName = destination.getBucketName();\n      // Avoid copy across locations or storage classes.\n      if (!srcBucketName.equals(dstBucketName)) {\n        StorageResourceId srcBucketResourceId = new StorageResourceId(srcBucketName);\n        GoogleCloudStorageItemInfo srcBucketInfo =\n            getGoogleCloudStorageItemInfo(gcsImpl, bucketInfoCache, srcBucketResourceId);\n        if (!srcBucketInfo.exists()) {\n          throw new FileNotFoundException(\"Bucket not found: \" + srcBucketName);\n        }\n\n        StorageResourceId dstBucketResourceId = new StorageResourceId(dstBucketName);\n        GoogleCloudStorageItemInfo dstBucketInfo =\n            getGoogleCloudStorageItemInfo(gcsImpl, bucketInfoCache, dstBucketResourceId);\n        if (!dstBucketInfo.exists()) {\n          throw new FileNotFoundException(\"Bucket not found: \" + dstBucketName);\n        }\n\n        // TODO: Restrict this only when copy-with-rewrite is enabled\n        if (!srcBucketInfo.getLocation().equals(dstBucketInfo.getLocation())) {\n          throw new UnsupportedOperationException(\n              \"This operation is not supported across two different storage locations.\");\n        }\n\n        if (!srcBucketInfo.getStorageClass().equals(dstBucketInfo.getStorageClass())) {\n          throw new UnsupportedOperationException(\n              \"This operation is not supported across two different storage classes.\");","sourceCodeStart":809,"sourceCodeEnd":845,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleCloudStorage.java#L809-L845","documentation":"validateCopyArguments checks buckets before a cross-bucket copy: it resolves the source bucket's info (through a bucketInfoCache) and, if that bucket does not exist, throws FileNotFoundException(\"Bucket not found: \" + srcBucketName). The check exists because cross-bucket copies require bucket metadata (location, storage class) which cannot be fetched for a nonexistent bucket.","triggerScenarios":"Calling copy() where source and destination bucket names differ and the SOURCE bucket does not exist or is not visible to the project/credentials — e.g. typo'd bucket, deleted bucket, or a bucket in another project without access (which surfaces as not-found).","commonSituations":"Typo in the gs:// source URL; bucket deleted between job submission and run; credentials scoped to a different project where the bucket is invisible; distcp configs copied between environments.","solutions":["Correct the source bucket name in the path/configuration","Verify the bucket exists and is reachable with the same credentials: gsutil ls gs://<src-bucket>","If the bucket belongs to another project, grant the service account access there"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the source bucket exists before cross-bucket copy\nGoogleCloudStorageItemInfo info = gcs.getItemInfo(new StorageResourceId(srcBucket));\nif (!info.exists()) {\n  throw new FileNotFoundException(\"Source bucket missing: \" + srcBucket);\n}\ngcs.copy(map);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate gs:// bucket names at configuration load time","Run gsutil ls on both buckets under job credentials as a pre-flight check","Grant cross-project bucket access where needed — invisibility looks like absence"],"tags":["gcs","hadoop-gcp","copy","bucket-not-found","validation"],"backgroundTag":"bucket-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}