{"record":{"id":"8072cbd8b3c5bb92","repo":"apache/hadoop","slug":"owner-null-group-null","errorCode":null,"errorMessage":"owner == null && group == null","messagePattern":"owner == null && group == null","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java","lineNumber":1282,"sourceCode":"      List<String> decodeResponse(Map<?, ?> json) throws IOException {\n        return JsonUtilClient.toXAttrNames(json);\n      }\n    }.run();\n  }\n\n  @Override\n  public void removeXAttr(Path p, String name) throws IOException {\n    statistics.incrementWriteOps(1);\n    storageStatistics.incrementOpCounter(OpType.REMOVE_XATTR);\n    final HttpOpParam.Op op = PutOpParam.Op.REMOVEXATTR;\n    new FsPathRunner(op, p, new XAttrNameParam(name)).run();\n  }\n\n  @Override\n  public void setOwner(final Path p, final String owner, final String group\n  ) throws IOException {\n    if (owner == null && group == null) {\n      throw new IOException(\"owner == null && group == null\");\n    }\n\n    statistics.incrementWriteOps(1);\n    storageStatistics.incrementOpCounter(OpType.SET_OWNER);\n    final HttpOpParam.Op op = PutOpParam.Op.SETOWNER;\n    new FsPathRunner(op, p,\n        new OwnerParam(owner), new GroupParam(group)\n    ).run();\n  }\n\n  @Override\n  public void setPermission(final Path p, final FsPermission permission\n  ) throws IOException {\n    statistics.incrementWriteOps(1);\n    storageStatistics.incrementOpCounter(OpType.SET_PERMISSION);\n    final HttpOpParam.Op op = PutOpParam.Op.SETPERMISSION;\n    new FsPathRunner(op, p,new PermissionParam(permission)).run();\n  }","sourceCodeStart":1264,"sourceCodeEnd":1300,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java#L1264-L1300","documentation":"setOwner in WebHdfsFileSystem requires that at least one of owner and group be non-null. Passing null for both would issue a SETOWNER request that changes nothing, so the client rejects it with IOException before incrementing write statistics or contacting the NameNode. Set either a new owner, a new group, or both.","triggerScenarios":"Calling fs.setOwner(path, owner, group) where both arguments are null. This commonly happens when optional owner and group values are read from configuration or a request object and neither was populated.","commonSituations":"A generic metadata-sync utility calls setOwner for every file even when no owner/group change was requested; empty form or CLI fields become null; refactoring a signature leaves a stale null argument.","solutions":["Skip the setOwner call when owner == null && group == null.","Require at least one non-null value at the application boundary and fail with a clear validation message.","If only one field should change, pass the current or desired value for that field and null for the field to leave unchanged.","Add a unit test for the no-change case in code that forwards user-supplied ownership metadata."],"exampleFix":"// before\nfs.setOwner(path, owner, group); // both may be null\n\n// after\nif (owner != null || group != null) {\n  fs.setOwner(path, owner, group);\n}","handlingStrategy":"validation","validationCode":"if (owner == null && group == null) {\n  throw new IllegalArgumentException(\"setOwner requires a non-null owner or group; skip the call for no-op updates\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.setOwner(path, owner, group);\n} catch (IOException e) {\n  if (\"owner == null && group == null\".equals(e.getMessage())) {\n    throw new IllegalArgumentException(\"Ownership update requested without an owner or group\", e);\n  }\n  throw e;\n}","preventionTips":["Validate owner/group request fields at the API boundary.","Skip no-op metadata updates instead of forwarding them to HDFS.","Cover the both-null case in unit tests for metadata synchronization code."],"tags":["java","hadoop","webhdfs","input-validation","setowner"],"backgroundTag":"invalid-argument-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}