{"record":{"id":"f8aa79e77bdc5f4e","repo":"apache/hadoop","slug":"cannot-parse-nsquota","errorCode":null,"errorMessage":"Cannot parse nsQuota: {}","messagePattern":"Cannot parse nsQuota: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java","lineNumber":986,"sourceCode":"\n  /**\n   * Set quota for a mount table entry.\n   *\n   * @param parameters Parameters of the quota.\n   * @param i Index in the parameters.\n   */\n  private boolean setQuota(String[] parameters, int i) throws IOException {\n    long nsQuota = HdfsConstants.QUOTA_DONT_SET;\n    long ssQuota = HdfsConstants.QUOTA_DONT_SET;\n\n    String mount = parameters[i++];\n    while (i < parameters.length) {\n      if (parameters[i].equals(\"-nsQuota\")) {\n        i++;\n        try {\n          nsQuota = Long.parseLong(parameters[i]);\n        } catch (Exception e) {\n          throw new IllegalArgumentException(\n              \"Cannot parse nsQuota: \" + parameters[i]);\n        }\n      } else if (parameters[i].equals(\"-ssQuota\")) {\n        i++;\n        try {\n          ssQuota = StringUtils.TraditionalBinaryPrefix\n              .string2long(parameters[i]);\n        } catch (Exception e) {\n          throw new IllegalArgumentException(\n              \"Cannot parse ssQuota: \" + parameters[i]);\n        }\n      } else {\n        throw new IllegalArgumentException(\n            \"Invalid argument : \" + parameters[i]);\n      }\n\n      i++;\n    }","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java#L968-L1004","documentation":"Thrown by HDFS Router-Based Federation's admin CLI: dfsrouteradmin -setQuota parses the token after -nsQuota with Long.parseLong. nsQuota is a namespace quota (a count of files and directories), so only a plain signed 64-bit integer is accepted; the value is validated client-side before any RPC reaches the Router. Any other shape -- binary suffixes, decimals, letters -- raises this IllegalArgumentException.","triggerScenarios":"hdfs dfsrouteradmin -setQuota /mount -nsQuota 100GB (suffix belongs to -ssQuota only); -nsQuota 1.5; -nsQuota abc; a value larger than Long.MAX_VALUE; an unquoted shell variable expanding to an empty or malformed token.","commonSituations":"Users carry over habits from 'hdfs dfsadmin -setSpaceQuota 100g' and paste unit suffixes onto -nsQuota. Scripts that assemble the command from user input or unquoted $VARIABLES also hit it. New RBF operators confusing namespace quota with storage-space quota.","solutions":["Pass a plain integer for -nsQuota, e.g. -nsQuota 100000 (files/directories count, no unit)","Put size units on -ssQuota instead, which accepts TraditionalBinaryPrefix values like 100GB, 5t, 2TB","If the value comes from a script, quote it and assert it matches ^-?[0-9]+$ before invoking the CLI","To remove quotas use 'hdfs dfsrouteradmin -clrQuota <path>' rather than magic numbers"],"exampleFix":"# before\nhdfs dfsrouteradmin -setQuota /mount -nsQuota 100GB\n# after\nhdfs dfsrouteradmin -setQuota /mount -nsQuota 100000 -ssQuota 100GB","handlingStrategy":"validation","validationCode":"# shell wrapper: verify -nsQuota value is a plain integer before invoking the CLI\nNS=\"$1\"\nif ! [[ \"$NS\" =~ ^-?[0-9]+$ ]]; then\n  echo \"nsQuota must be a plain integer (got: $NS)\" >&2; exit 2\nfi\nhdfs dfsrouteradmin -setQuota \"$MOUNT\" -nsQuota \"$NS\"","typeGuard":null,"tryCatchPattern":"In Java wrappers around RouterAdmin, catch IllegalArgumentException and rethrow with the command usage, since the CLI exits nonzero on the first malformed flag.","preventionTips":["Remember -nsQuota takes a bare count; unit suffixes only on -ssQuota","Quote every variable expanded into the command line","Dry-run quota commands in a staging mount before production runbooks"],"tags":["hdfs","rbf","federation","quota","cli","number-format"],"backgroundTag":"number-format-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}