{"record":{"id":"9f0981ad377c5878","repo":"apache/hadoop","slug":"file-version-is-invalid-9f0981","errorCode":null,"errorMessage":"file VERSION is invalid.","messagePattern":"file VERSION is invalid\\.","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java","lineNumber":647,"sourceCode":"      this.layoutVersion = toLayoutVersion;\n    } else {\n      setLayoutVersion(props, sd);\n    }\n    setcTime(props, sd);\n    checkStorageType(props, sd);\n    setClusterId(props, layoutVersion, sd);\n    \n    // Read NamespaceID in version before federation\n    if (!DataNodeLayoutVersion.supports(\n        LayoutVersion.Feature.FEDERATION, layoutVersion)) {\n      setNamespaceID(props, sd);\n    }\n    \n\n    // valid storage id, storage id may be empty\n    String ssid = props.getProperty(\"storageID\");\n    if (ssid == null) {\n      throw new InconsistentFSStateException(sd.getRoot(), \"file \"\n          + STORAGE_FILE_VERSION + \" is invalid.\");\n    }\n    String sid = sd.getStorageUuid();\n    if (!(sid == null || sid.equals(\"\") ||\n          ssid.equals(\"\") || sid.equals(ssid))) {\n      throw new InconsistentFSStateException(sd.getRoot(),\n          \"has incompatible storage Id.\");\n    }\n\n    if (sid == null) { // update id only if it was null\n      sd.setStorageUuid(ssid);\n    }\n\n    // Update the datanode UUID if present.\n    if (props.getProperty(\"datanodeUuid\") != null) {\n      String dnUuid = props.getProperty(\"datanodeUuid\");\n\n      if (getDatanodeUuid() == null) {","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java#L629-L665","documentation":"While reading a pre-federation storage directory's VERSION file, DataStorage requires a storageID property. If props.getProperty(\"storageID\") is null the file is malformed/incomplete for its layout version, and InconsistentFSStateException ('file VERSION is invalid.') aborts use of that directory.","triggerScenarios":"A pre-federation data dir whose VERSION file lacks the storageID line - truncated write from a crash, manual editing, or a VERSION produced by non-Hadoop tooling.","commonSituations":"Power loss / kill -9 during a VERSION write leaving a partial file; hand-edited or script-mangled VERSION files; very old storage dirs copied incompletely between hosts.","solutions":["Restore the VERSION file from backup or from the sibling block-pool storage copies","If the directory's data is dispensable, remove/reformat the directory so the DN recreates it cleanly","Never hand-edit VERSION; manage DN storage only through Hadoop tooling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Properties props = new Properties();\ntry (Reader r = Files.newBufferedReader(dir.resolve(\"current/VERSION\"))) {\n  props.load(r);\n}\nif (props.getProperty(\"storageID\") == null) {\n  throw new IOException(\"VERSION file invalid (no storageID): \" + dir);\n}","typeGuard":null,"tryCatchPattern":"catch (InconsistentFSStateException e) {\n  // VERSION malformed: restore from backup or reformat the directory\n  logAndHaltStartupWithGuidance(e);\n}","preventionTips":["Keep backups of VERSION files (or whole metadata dirs) before maintenance on old clusters","Use only Hadoop tooling to format/rollback storage; never script edits to VERSION","After crashes, validate all VERSION files parse completely before restarting"],"tags":["hadoop","hdfs","datanode","storage","version-file","corruption"],"backgroundTag":"corrupt-version-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}