{"record":{"id":"c4742d155579790e","repo":"apache/hadoop","slug":"invalid-storage-type-null","errorCode":null,"errorMessage":"Invalid storage type(null)","messagePattern":"Invalid storage type\\(null\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java","lineNumber":2679,"sourceCode":"          UnresolvedPathException.class,\n          SnapshotAccessControlException.class);\n    }\n  }\n\n  /**\n   * Sets or resets quotas by storage type for a directory.\n   * @see ClientProtocol#setQuota(String, long, long, StorageType)\n   */\n  void setQuotaByStorageType(String src, StorageType type, long quota)\n      throws IOException {\n    checkOpen();\n    if (quota <= 0 && quota != HdfsConstants.QUOTA_DONT_SET &&\n        quota != HdfsConstants.QUOTA_RESET) {\n      throw new IllegalArgumentException(\"Invalid values for quota :\" +\n          quota);\n    }\n    if (type == null) {\n      throw new IllegalArgumentException(\"Invalid storage type(null)\");\n    }\n    if (!type.supportTypeQuota()) {\n      throw new IllegalArgumentException(\n          \"Don't support Quota for storage type : \" + type.toString());\n    }\n    try (TraceScope ignored = newPathTraceScope(\"setQuotaByStorageType\", src)) {\n      namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, quota, type);\n    } catch (RemoteException re) {\n      throw re.unwrapRemoteException(AccessControlException.class,\n          FileNotFoundException.class,\n          QuotaByStorageTypeExceededException.class,\n          UnresolvedPathException.class,\n          SnapshotAccessControlException.class);\n    }\n  }\n\n  /**\n   * set the modification and access time of a file.","sourceCodeStart":2661,"sourceCodeEnd":2697,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L2661-L2697","documentation":"DFSClient.setQuotaByStorageType requires a concrete StorageType; a null type is rejected immediately with IllegalArgumentException('Invalid storage type(null)'), before quota values are even considered. In practice the null usually arrives from an optional parameter (CLI flag, JSON field, config key) that was omitted and never defaulted.","triggerScenarios":"Calling setQuotaByStorageType(src, null, quota); a CLI layer mapping a missing -storageType flag to null; deserialization of requests where the type field is absent; test code passing an unset variable.","commonSituations":"Custom admin tooling fronting quota APIs; REST/JSON drivers where 'storageType' is optional but this call requires it; refactors that change the parameter order or type.","solutions":["Require the type at your boundary: validate non-null (and one of DISK/SSD/ARCHIVE/RAM_DISK/NVDIMM) before invoking the client.","Fail fast with a clear message listing valid types instead of letting null reach the RPC layer.","Fix the caller that dropped or never parsed the parameter."],"exampleFix":"// before\nclient.setQuotaByStorageType(dir, type, quota); // type == null\n// IllegalArgumentException: Invalid storage type(null)\n\n// after\nObjects.requireNonNull(type, 'storage type must be one of DISK, SSD, ARCHIVE, RAM_DISK, NVDIMM');\nclient.setQuotaByStorageType(dir, type, quota);","handlingStrategy":"validation","validationCode":"if (type == null) {\n  throw new IllegalArgumentException(\"storage type required: DISK, SSD, ARCHIVE, RAM_DISK, NVDIMM\");\n}\nclient.setQuotaByStorageType(dir, type, quota);","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"storage type\")) {\n    // missing parameter upstream: reject the request at your API boundary\n  } else { throw e; }\n}","preventionTips":["Make storage type a required parameter in your tooling, validated at parse time.","Avoid Optional/null plumbing for enum parameters; use explicit parsed request objects.","Unit-test the null path of every wrapper around quota APIs."],"tags":["hdfs","quota","storage-type","null-argument","argument-validation"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}