{"record":{"id":"a9650bf7c5fdaa0f","repo":"apache/hadoop","slug":"a-valid-name-and-value-must-be-specified","errorCode":null,"errorMessage":"A valid name and value must be specified.","messagePattern":"A valid name and value must be specified\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java","lineNumber":1132,"sourceCode":"   * Set the value of an attribute for a non-root path.\n   *\n   * @param path The path on which to set the attribute\n   * @param name The attribute to set\n   * @param value The byte value of the attribute to set (encoded in latin-1)\n   * @param flag The mode in which to set the attribute\n   * @throws IOException If there was an issue setting the attribute on Azure\n   * @throws IllegalArgumentException If name is null or empty or if value is null\n   */\n  @Override\n  public void setXAttr(final Path path,\n      final String name,\n      final byte[] value,\n      final EnumSet<XAttrSetFlag> flag)\n      throws IOException {\n    LOG.debug(\"AzureBlobFileSystem.setXAttr path: {}\", path);\n\n    if (name == null || name.isEmpty() || value == null) {\n      throw new IllegalArgumentException(\"A valid name and value must be specified.\");\n    }\n\n    Path qualifiedPath = makeQualified(path);\n\n    try {\n      TracingContext tracingContext = new TracingContext(clientCorrelationId,\n          fileSystemId, FSOperationType.SET_ATTR, true, tracingHeaderFormat,\n          listener);\n      Hashtable<String, String> properties = getAbfsStore()\n          .getPathStatus(qualifiedPath, tracingContext);\n      String xAttrName = ensureValidAttributeName(name);\n      boolean xAttrExists = properties.containsKey(xAttrName);\n      XAttrSetFlag.validate(name, xAttrExists, flag);\n\n      String xAttrValue = getAbfsStore().decodeAttribute(value);\n      properties.put(xAttrName, xAttrValue);\n      getAbfsStore().setPathProperties(qualifiedPath, properties, tracingContext);\n    } catch (AzureBlobFileSystemException ex) {","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java#L1114-L1150","documentation":"Thrown by AzureBlobFileSystem.setXAttr when the attribute name is null/empty or the value byte array is null. ABFS stores xattrs as path properties on the service, and a null value cannot be represented — removal is a separate removeXAttr operation. The check runs before any service call, so no network round trip is made.","triggerScenarios":"Calling fs.setXAttr(path, null, value, flags), fs.setXAttr(path, \"\", value, flags), or fs.setXAttr(path, name, null, flags).","commonSituations":"Code ported from HDFS, which permits a null xattr value (treated as empty) with the CREATE flag; dynamically built attribute names that concatenate to an empty string; intending to delete an attribute via setXAttr instead of removeXAttr.","solutions":["Pass an empty byte[0] instead of null when you mean 'no value'.","Use fs.removeXAttr(path, name) to delete an attribute.","Validate name is non-empty and value is non-null before the call."],"exampleFix":"// before\nfs.setXAttr(path, \"user.tag\", null, EnumSet.of(XAttrSetFlag.CREATE));\n\n// after\nfs.setXAttr(path, \"user.tag\", new byte[0], EnumSet.of(XAttrSetFlag.CREATE));","handlingStrategy":"validation","validationCode":"if (name == null || name.isEmpty() || value == null) {\n  throw new IllegalArgumentException(\"setXAttr requires non-empty name and non-null value\");\n}\nfs.setXAttr(path, name, value, flags);","typeGuard":"static boolean isValidXAttrCall(String name, byte[] value) {\n  return (name != null && !name.isEmpty()) && value != null;\n}","tryCatchPattern":"try {\n  fs.setXAttr(path, name, value, flags);\n} catch (IllegalArgumentException e) {\n  // argument bug: normalize and retry once with new byte[0], or rethrow\n}","preventionTips":["Remember ABFS (unlike HDFS) rejects null xattr values; use byte[0].","Use removeXAttr for deletion, never setXAttr(null).","Centralize xattr name construction with a non-empty assertion."],"tags":["azure-abfs","setxattr","xattr","illegal-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}