{"record":{"id":"98f1d09041bec83e","repo":"apache/hadoop","slug":"invalid-empty-cache-pool-name","errorCode":null,"errorMessage":"invalid empty cache pool name","messagePattern":"invalid empty cache pool name","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java","lineNumber":246,"sourceCode":"\n    if (info.getMaxRelativeExpiryMs() != null) {\n      long maxRelativeExpiryMs = info.getMaxRelativeExpiryMs();\n      if (maxRelativeExpiryMs < 0l) {\n        throw new InvalidRequestException(\"Max relative expiry is negative.\");\n      }\n      if (maxRelativeExpiryMs > Expiration.MAX_RELATIVE_EXPIRY_MS) {\n        throw new InvalidRequestException(\"Max relative expiry is too big.\");\n      }\n    }\n    validateName(info.poolName);\n  }\n\n  public static void validateName(String poolName) throws IOException {\n    if (poolName == null || poolName.isEmpty()) {\n      // Empty pool names are not allowed because they would be highly\n      // confusing.  They would also break the ability to list all pools\n      // by starting with prevKey = \"\"\n      throw new IOException(\"invalid empty cache pool name\");\n    }\n  }\n}\n","sourceCodeStart":228,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java#L228-L250","documentation":"CachePoolInfo.validateName() throws IOException when the pool name is null or empty. Empty names are rejected because listing iterates pools in lexicographic order starting from prevKey \"\" — an empty name would be unlistable and confusing.","triggerScenarios":"addCachePool/modifyCachePool (or setPoolName) where the name is empty string or null: template-built names with a missing variable, whitespace-trimmed input, or default null from an unset config.","commonSituations":"Automation that derives pool names from directory names where the derivation returns \"\"; i18n input trimmed to empty; config key miss returning null.","solutions":["Supply a non-empty pool name; reject blank input before calling the API.","If the name comes from config, fail fast on missing values rather than passing null.","Use trim() + isEmpty() pre-checks in the caller."],"exampleFix":"// before\ndfs.addCachePool(new CachePoolInfo(poolName)); // poolName may be \"\"\n\n// after\nString name = poolName == null ? \"\" : poolName.trim();\nPreconditions.checkArgument(!name.isEmpty(), \"cache pool name must not be empty\");\ndfs.addCachePool(new CachePoolInfo(name));","handlingStrategy":"validation","validationCode":"String name = poolName == null ? null : poolName.trim();\nif (name == null || name.isEmpty()) {\n  throw new IllegalArgumentException(\"cache pool name must be non-empty\");\n}\ndfs.addCachePool(new CachePoolInfo(name));","typeGuard":null,"tryCatchPattern":"try { dfs.addCachePool(new CachePoolInfo(name)); }\ncatch (IOException e) {\n  if (e.getMessage().contains(\"invalid empty cache pool name\")) { /* reject input early */ }\n}","preventionTips":["Derive pool names only from validated, non-blank sources.","Fail fast on missing config keys instead of defaulting to null names.","Add integration tests for pool CRUD with blank-name inputs."],"tags":["hdfs","caching","validation","naming"],"backgroundTag":"input-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}