{"record":{"id":"4d4987da1e576830","repo":"apache/hadoop","slug":"username-null-groupname-null-4d4987","errorCode":null,"errorMessage":"username == null && groupname == null","messagePattern":"username == null && groupname == null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java","lineNumber":2119,"sourceCode":"      public Void doCall(final Path p) throws IOException {\n        dfs.setPermission(getPathName(p), permission);\n        return null;\n      }\n\n      @Override\n      public Void next(final FileSystem fs, final Path p)\n          throws IOException {\n        fs.setPermission(p, permission);\n        return null;\n      }\n    }.resolve(this, absF);\n  }\n\n  @Override\n  public void setOwner(Path p, final String username, final String groupname)\n      throws IOException {\n    if (username == null && groupname == null) {\n      throw new IOException(\"username == null && groupname == null\");\n    }\n    statistics.incrementWriteOps(1);\n    storageStatistics.incrementOpCounter(OpType.SET_OWNER);\n    Path absF = fixRelativePart(p);\n    new FileSystemLinkResolver<Void>() {\n      @Override\n      public Void doCall(final Path p) throws IOException {\n        dfs.setOwner(getPathName(p), username, groupname);\n        return null;\n      }\n\n      @Override\n      public Void next(final FileSystem fs, final Path p)\n          throws IOException {\n        fs.setOwner(p, username, groupname);\n        return null;\n      }\n    }.resolve(this, absF);","sourceCodeStart":2101,"sourceCodeEnd":2137,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java#L2101-L2137","documentation":"setOwner(Path, String username, String groupname) requires at least one of username or groupname to be non-null; passing both as null is a contract violation with no valid RPC to send, so the client throws IOException('username == null && groupname == null') before contacting the NameNode. This is a local argument-validation failure, not a cluster error.","triggerScenarios":"Calling setOwner(p, null, null) — typically from code that reads owner/group from config or a metadata file and forwards nulls unchecked, or a chown-like tool invoked with neither -user nor -group.","commonSituations":"Distcp/permission-sync tools that copy owner/group fields and pass null when the source metadata lacks them; wrappers that map 'keep unchanged' to null; CLI-ish tools where optional flags leave both fields unset.","solutions":["Validate arguments before the call: require at least one of owner/group, or make null mean 'no-op' and skip the call entirely.","Default the null field to the current value from getFileStatus(p).getOwner()/getGroup() when intent is 'set one, keep other'.","Fix the upstream config/metadata that produced nulls.","If writing a wrapper API, overload setOwner into setOwnerOnly/setGroupOnly variants that never see two nulls."],"exampleFix":"// before\nfs.setOwner(path, newOwner, newGroup); // both may be null -> IOException\n\n// after\nif (newOwner == null && newGroup == null) {\n  return; // nothing to change\n}\nfs.setOwner(path, newOwner, newGroup);","handlingStrategy":"validation","validationCode":"if (username != null || groupname != null) {\n  fs.setOwner(path, username, groupname);\n} // else: no-op, do not call","typeGuard":null,"tryCatchPattern":"try {\n  fs.setOwner(path, user, group);\n} catch (IOException e) {\n  if (!\"username == null && groupname == null\".equals(e.getMessage())) throw e;\n  // skip: nothing requested\n}","preventionTips":["Model 'unchanged' explicitly in wrapper APIs (Optional/absent) instead of null.","Validate ownership-change requests at the tool's argument parsing layer.","When copying metadata, fetch current owner/group first and substitute them for nulls."],"tags":["hdfs","setowner","argument-validation","permissions","distributed-filesystem"],"backgroundTag":"invalid-argument-null-check","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}