{"record":{"id":"5222a646b90eb466","repo":"apache/hadoop","slug":"failed-to-create-multipartupload-with-key-s","errorCode":null,"errorMessage":"Failed to create MultipartUpload with key: %s","messagePattern":"Failed to create MultipartUpload with key: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/FileStore.java","lineNumber":335,"sourceCode":"          }\n\n          objectInfos.add(obj);\n        }\n      }\n      return new ListObjectsResponse(objectInfos, new ArrayList<>(commonPrefixes));\n    }\n  }\n\n  @Override\n  public MultipartUpload createMultipartUpload(String key) {\n    Preconditions.checkArgument(!Strings.isNullOrEmpty(key), \"Key should not be empty.\");\n\n    String uploadId = UUIDUtils.random();\n    Path uploadDir = uploadPath(key, uploadId);\n    if (uploadDir.toFile().mkdirs()) {\n      return new MultipartUpload(key, uploadId, MIN_PART_SIZE, MAX_PART_COUNT);\n    } else {\n      throw new RuntimeException(\"Failed to create MultipartUpload with key: \" + key);\n    }\n  }\n\n  private Path uploadPath(String key, String uploadId) {\n    return Paths.get(root, STAGING_DIR, encode(key), uploadId);\n  }\n\n  @Override\n  public Part uploadPart(\n      String key, String uploadId, int partNum,\n      InputStreamProvider streamProvider, long contentLength) {\n    Preconditions.checkArgument(!Strings.isNullOrEmpty(key), \"Key should not be empty.\");\n\n    File uploadDir = uploadPath(key, uploadId).toFile();\n    if (!uploadDir.exists()) {\n      throw new RuntimeException(\"cannot locate the upload id: \" + uploadId);\n    }\n","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/FileStore.java#L317-L353","documentation":"FileStore.createMultipartUpload() represents an upload as a staging directory <root>/__STAGING__/<encodedKey>/<uploadId>. If uploadDir.mkdirs() returns false the RuntimeException 'Failed to create MultipartUpload with key' is thrown — the connector could not create the per-upload staging directory on local disk, so the multipart upload cannot even begin.","triggerScenarios":"createMultipartUpload(key) when any path component under root/__STAGING__/<encoded key> cannot be created: root or staging not writable, a regular file sitting where a directory is needed, disk full, or the store root itself was deleted after initialize().","commonSituations":"A previous aborted job left a FILE (not directory) at the encoded-key path inside __STAGING__; read-only or full volumes in test containers; cleanup code that wipes the root between operations while the filesystem layer still holds a FileStore instance.","solutions":["Inspect and repair the staging tree: ls -lR <root>/__STAGING__ and remove stray regular files blocking directory creation","Verify the root volume is writable and has space (df -h <root>; touch <root>/.probe)","Recreate the store root directory if it was deleted post-initialize, or re-initialize the FileStore","Delete the __STAGING__ subtree entirely (it only holds in-flight uploads) and retry the upload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-create the staging tree so createMultipartUpload only makes leaf dirs\njava.nio.file.Path staging = java.nio.file.Paths.get(root, \"__STAGING__\");\njava.nio.file.Files.createDirectories(staging);\nif (!java.nio.file.Files.isWritable(staging)) {\n  throw new IOException(\"filestore staging dir not writable: \" + staging);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the store root on a writable local volume and never delete it while the store is active","Wipe <root>/__STAGING__ between test runs only when no upload is in flight","Avoid creating plain files that collide with __STAGING__ paths (the encoded-key path must be a directory)","Re-initialize the FileStore after anything deletes the root directory"],"tags":["hadoop","tos","filestore","multipart-upload","staging"],"backgroundTag":"multipart-upload-init-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}