{"record":{"id":"12c3629b8315d5e6","repo":"apache/hadoop","slug":"home-dir-should-start-with-homedir","errorCode":null,"errorMessage":"Home dir should start with /:{homedir}","messagePattern":"Home dir should start with /:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java","lineNumber":223,"sourceCode":"   * Add config variable for homedir for default mount table\n   * @param conf - add to this conf\n   * @param homedir - the home dir path starting with slash\n   */\n  public static void setHomeDirConf(final Configuration conf,\n      final String homedir) {\n    setHomeDirConf(conf, getDefaultMountTableName(conf), homedir);\n  }\n  \n  /**\n   * Add config variable for homedir the specified mount table\n   * @param conf - add to this conf\n   * @param homedir - the home dir path starting with slash\n   * @param mountTableName - the mount table.\n   */\n  public static void setHomeDirConf(final Configuration conf,\n              final String mountTableName, final String homedir) {\n    if (!homedir.startsWith(\"/\")) {\n      throw new IllegalArgumentException(\"Home dir should start with /:\"\n          + homedir);\n    }\n    conf.set(getConfigViewFsPrefix(mountTableName) + \".\" +\n        Constants.CONFIG_VIEWFS_HOMEDIR, homedir);\n  }\n  \n  /**\n   * Get the value of the home dir conf value for default mount table\n   * @param conf - from this conf\n   * @return home dir value, null if variable is not in conf\n   */\n  public static String getHomeDirValue(final Configuration conf) {\n    return getHomeDirValue(conf, getDefaultMountTableName(conf));\n  }\n  \n  /**\n   * Get the value of the home dir conf value for specified mount table\n   * @param conf - from this conf","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java#L205-L241","documentation":"ConfigUtil.setHomeDirConf writes fs.viewfs.mounttable.<name>.homedir into a Configuration for ViewFs. It enforces that the home dir starts with '/', because a ViewFs home must be an absolute path inside the mount-table namespace; otherwise IllegalArgumentException('Home dir should start with /:<homedir>') is thrown before the property is set.","triggerScenarios":"Calling ConfigUtil.setHomeDirConf(conf, mountTable, 'user/alice') or setHomeDirDirConf(...) with a relative path; composing the home dir from a username without a base.","commonSituations":"Programmatic mount-table setup that concatenates 'user/' + name instead of '/user/' + name; home values read from properties that lack the leading slash.","solutions":["Pass an absolute path: '/user/alice'","Normalize before the call: homedir = homedir.startsWith('/') ? homedir : '/' + homedir","Derive per-user homes from a fixed '/user' base constant"],"exampleFix":"// before\nConfigUtil.setHomeDirConf(conf, mountTable, \"user/\" + user);\n\n// after\nConfigUtil.setHomeDirConf(conf, mountTable, \"/user/\" + user);","handlingStrategy":"validation","validationCode":"static String absoluteHome(String homeDir) {\n  if (!homeDir.startsWith(\"/\")) {\n    throw new IllegalArgumentException(\"Home dir must be absolute: \" + homeDir);\n  }\n  return homeDir;\n}\nConfigUtil.setHomeDirConf(conf, mountTable, absoluteHome(home));","typeGuard":null,"tryCatchPattern":"Catch IllegalArgumentException from setHomeDirConf; the message shows the offending value, so fail config generation with the corrected absolute path.","preventionTips":["Always build homes from a '/user' base","Normalize values read from properties before passing them","Unit-test mount-table generators with relative inputs"],"tags":["hadoop","viewfs","configuration","path-validation","home-dir"],"backgroundTag":"expected-absolute-path","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}