{"record":{"id":"9d69cb1c77d23e47","repo":"apache/hadoop","slug":"har-rename-not-allowed","errorCode":null,"errorMessage":"Har: rename not allowed","messagePattern":"Har: rename not allowed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":756,"sourceCode":"        fs.close();\n      } catch(IOException ie) {\n        //this might already be closed\n        // ignore\n      }\n    }\n  }\n  \n  /**\n   * Not implemented.\n   */\n  @Override\n  public boolean setReplication(Path src, short replication) throws IOException{\n    throw new IOException(\"Har: setReplication not allowed\");\n  }\n\n  @Override\n  public boolean rename(Path src, Path dst) throws IOException {\n    throw new IOException(\"Har: rename not allowed\");\n  }\n\n  @Override\n  public FSDataOutputStream append(Path f) throws IOException {\n    throw new IOException(\"Har: append not allowed\");\n  }\n\n  /**\n   * Not implemented.\n   */\n  @Override\n  public boolean truncate(Path f, long newLength) throws IOException {\n    throw new IOException(\"Har: truncate not allowed\");\n  }\n\n  /**\n   * Not implemented.\n   */","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L738-L774","documentation":"rename is rejected with 'Har: rename not allowed': member names are recorded in the archive index, which is immutable after `hadoop archive` completes, so no path inside a har can be moved. This override throws unconditionally for all src/dst under har://.","triggerScenarios":"fs.rename(src, dst) where either path is under har:// — atomic-commit patterns (write temp then rename), directory reorganization jobs, and generic file-movement utilities are the usual callers.","commonSituations":"Output committers that stage to a temp name and rename into place; migration scripts unaware the destination tree contains har mounts; cleanup/rename tooling run over mixed trees.","solutions":["Do renames in a staging directory on the underlying HDFS before creating the archive","If the layout must change, rebuild the archive from source with the new structure using `hadoop archive`","Make commit/rename logic fall back to copy+delete on the underlying filesystem when the destination is read-only, or reject har destinations up front"],"exampleFix":"// before\nfs.rename(tmpPath, new Path(\"har://hdfs-nn:8020/a/data.har/final\"));\n\n// after\n// rename in HDFS staging, then archive the finalized tree\nhdfs.rename(new Path(\"/a/staging/final\"), new Path(\"/a/data/final\"));\n// hadoop archive -archiveName data.har -p /a/data /a","handlingStrategy":"validation","validationCode":"if (\"har\".equals(src.toUri().getScheme()) || \"har\".equals(dst.toUri().getScheme())) {\n  throw new UnsupportedOperationException(\"rename is not supported on har; rebuild the archive instead\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.rename(src, dst);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"not allowed\")) {\n    // destination is read-only: fall back to copy-on-write semantics on the underlying fs\n  }\n  throw e;\n}","preventionTips":["Never rely on atomic rename commits on output trees that may resolve to har://","Do layout changes in HDFS staging before creating the archive","Teach generic file-movement tools to reject read-only destinations up front"],"tags":["hadoop","har-filesystem","read-only","rename","atomic-commit"],"backgroundTag":"read-only-filesystem-write","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}