{"record":{"id":"87a707a78a4f8956","repo":"apache/hadoop","slug":"bucket-s-not-found","errorCode":null,"errorMessage":"Bucket: %s not found.","messagePattern":"Bucket: (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/RawFileSystem.java","lineNumber":614,"sourceCode":"  private void stopAllServices() {\n    ThreadPools.shutdown(uploadThreadPool, 30, TimeUnit.SECONDS);\n    ThreadPools.shutdown(taskThreadPool, 30, TimeUnit.SECONDS);\n  }\n\n  @Override\n  public void initialize(URI name, Configuration conf) throws IOException {\n    super.initialize(name, conf);\n    setConf(conf);\n    this.scheme = FSUtils.scheme(conf, name);\n\n    // Username is the current user at the time the FS was instantiated.\n    this.username = UserGroupInformation.getCurrentUser().getShortUserName();\n    this.workingDir = new Path(\"/user\", username).makeQualified(name, null);\n    this.uri = URI.create(scheme + \"://\" + name.getAuthority());\n    this.bucket = this.uri.getAuthority();\n    this.storage = ObjectStorageFactory.create(scheme, bucket, getConf());\n    if (storage.bucket() == null) {\n      throw new FileNotFoundException(String.format(\"Bucket: %s not found.\", name.getAuthority()));\n    }\n\n    int taskThreadPoolSize =\n        getConf().getInt(ConfKeys.FS_TASK_THREAD_POOL_SIZE.key(storage.scheme()),\n            ConfKeys.FS_TASK_THREAD_POOL_SIZE_DEFAULT);\n    this.taskThreadPool = ThreadPools.newWorkerPool(TASK_THREAD_POOL_PREFIX, taskThreadPoolSize);\n\n    int uploadThreadPoolSize =\n        getConf().getInt(ConfKeys.FS_MULTIPART_THREAD_POOL_SIZE.key(storage.scheme()),\n            ConfKeys.FS_MULTIPART_THREAD_POOL_SIZE_DEFAULT);\n    this.uploadThreadPool =\n        ThreadPools.newWorkerPool(MULTIPART_THREAD_POOL_PREFIX, uploadThreadPoolSize);\n\n    if (storage.bucket().isDirectory()) {\n      fsOps = new DirectoryFsOps((DirectoryStorage) storage, this::objectToFileStatus);\n    } else {\n      fsOps = new DefaultFsOps(storage, getConf(), taskThreadPool, this::objectToFileStatus);\n    }","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/RawFileSystem.java#L596-L632","documentation":"initialize() throws FileNotFoundException(\"Bucket: %s not found.\") when ObjectStorageFactory.create(...).bucket() returns null, i.e. the bucket named in the tos:// URI authority could not be resolved/seen. The filesystem refuses to start so no operation silently targets the wrong place.","triggerScenarios":"new Path('tos://my-buckt/path') typos in the authority; bucket in another region with the wrong fs.tos.endpoint configured; credentials whose grant does not permit ListBuckets/HeadBucket on that name; URI built from unescaped or empty authority.","commonSituations":"Region/endpoint mismatch after bucket migration; missing or wrong fs.tos.access-key/secret-key or credentials provider; environment-specific config (core-site.xml) pointing at a different account; test configs hitting a bucket deleted between runs.","solutions":["Verify the bucket name spelling in the URI authority against the TOS console","Set the correct region endpoint (fs.tos.endpoint) for the bucket and retry","Validate credentials/permissions: the principal must be able to HeadBucket/ListBuckets on that bucket","Pre-flight in tests: assert the bucket is reachable before submitting jobs that assume it"],"exampleFix":"# before (core-site.xml)\n<property><name>fs.tos.endpoint</name><value>tos-cn-beijing.volces.com</value></property>\n# bucket actually lives in ap-southeast-1 -> initialize() fails with Bucket not found\n\n# after\n<property><name>fs.tos.endpoint</name><value>tos-ap-southeast-1.volces.com</value></property>","handlingStrategy":"validation","validationCode":"// pre-flight at job setup\nConfiguration c = new Configuration();\nc.set(\"fs.tos.endpoint\", expectedRegionEndpoint);\ntry (FileSystem fs = FileSystem.get(new URI(\"tos://\" + bucket + \"/\"), c)) {\n  fs.getFileStatus(new Path(\"/\")); // forces initialize(); fails fast with Bucket not found\n}","typeGuard":null,"tryCatchPattern":"try { fs = FileSystem.get(tosUri, conf); }\ncatch (FileNotFoundException e) {\n  if (e.getMessage().contains(\"Bucket:\")) { /* check bucket name, endpoint, credentials */ }\n  else throw e;\n}","preventionTips":["Pin fs.tos.endpoint to the bucket's region in core-site.xml","Validate bucket name and credentials in deploy checks before job submission","Centralize tos:// URI construction so authorities are built from config, not hand-typed"],"tags":["bucket-not-found","initialization","endpoint","credentials","tos"],"backgroundTag":"bucket-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}