{"record":{"id":"c48d4e1322dbe40a","repo":"apache/hadoop","slug":"value-cannot-be-blank","errorCode":null,"errorMessage":"value cannot be blank","messagePattern":"value cannot be blank","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/StorageSize.java","lineNumber":46,"sourceCode":"public class StorageSize {\n  private final StorageUnit unit;\n  private final double value;\n\n  /**\n   * Constucts a Storage Measure, which contains the value and the unit of\n   * measure.\n   *\n   * @param unit - Unit of Measure\n   * @param value - Numeric value.\n   */\n  public StorageSize(StorageUnit unit, double value) {\n    this.unit = unit;\n    this.value = value;\n  }\n\n  private static void checkState(boolean state, String errorString){\n    if(!state) {\n      throw new IllegalStateException(errorString);\n    }\n  }\n\n  public static StorageSize parse(String value) {\n    checkState(isNotBlank(value), \"value cannot be blank\");\n    String sanitizedValue = value.trim().toLowerCase(Locale.ENGLISH);\n    StorageUnit parsedUnit = null;\n    for (StorageUnit unit : StorageUnit.values()) {\n      if (sanitizedValue.endsWith(unit.getShortName()) ||\n          sanitizedValue.endsWith(unit.getLongName()) ||\n          sanitizedValue.endsWith(unit.getSuffixChar())) {\n        parsedUnit = unit;\n        break;\n      }\n    }\n\n    if (parsedUnit == null) {\n      throw new IllegalArgumentException(value + \" is not in expected format.\" +","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/StorageSize.java#L28-L64","documentation":"StorageSize.parse(String) converts a size literal like \"1000MB\" into a StorageUnit + double pair. Its first step is checkState(isNotBlank(value), \"value cannot be blank\"), so null, empty, or whitespace-only input fails immediately. Note the exception type is IllegalStateException (the checkState helper throws ISE), not IllegalArgumentException as for later format problems.","triggerScenarios":"StorageSize.parse(null), parse(\"\"), or parse(\"   \"); almost always the argument came straight from an unset or empty configuration property (conf.get(key) returning null or an empty string).","commonSituations":"A newly introduced size-typed config key with no default in the XML; a property defined with an empty <value/>; variable substitution (${...}) resolving to empty; a typo'd key name making conf.get() return null.","solutions":["Set a valid default with unit for the config key, e.g. conf.get(key, \"128MB\")","Null/blank-check the string before calling StorageSize.parse() and fail with a message naming the key","Fix the property name or the substitution expression so it cannot resolve to null/empty"],"exampleFix":"// before\nStorageSize size = StorageSize.parse(conf.get(\"some.size.key\")); // ISE if unset\n\n// after\nString raw = conf.get(\"some.size.key\", \"128MB\");\nif (StringUtils.isBlank(raw)) {\n  throw new IllegalArgumentException(\"some.size.key must be set, e.g. 128MB\");\n}\nStorageSize size = StorageSize.parse(raw);","handlingStrategy":"validation","validationCode":"String raw = conf.get(key, defaultWithUnit); // e.g. default \"128MB\"\nif (StringUtils.isBlank(raw)) {\n  throw new IllegalArgumentException(key + \" must be a non-empty <number><unit> value\");\n}\nStorageSize size = StorageSize.parse(raw);","typeGuard":null,"tryCatchPattern":"try {\n  size = StorageSize.parse(raw);\n} catch (IllegalStateException e) {\n  // blank input -> fail with the config key name for actionable context\n  throw new IllegalArgumentException(key + \" is unset/empty; expected e.g. 128MB\", e);\n}","preventionTips":["Always supply a unit-bearing default when reading size-typed config keys","Add config sanity checks at service startup rather than at first use","Lint configs for empty <value/> elements in CI"],"tags":["configuration","validation","parsing","storage","hadoop"],"backgroundTag":"missing-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}