{"record":{"id":"2f4e6162eabc01b1","repo":"apache/hadoop","slug":"invalid-replication-factor-repl-0","errorCode":null,"errorMessage":"Invalid replication factor {repl} <= 0","messagePattern":"Invalid replication factor (.+?) <= 0","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java","lineNumber":395,"sourceCode":"\n  private static String validatePath(CacheDirectiveInfo directive)\n      throws InvalidRequestException {\n    if (directive.getPath() == null) {\n      throw new InvalidRequestException(\"No path specified.\");\n    }\n    String path = directive.getPath().toUri().getPath();\n    if (!DFSUtil.isValidName(path)) {\n      throw new InvalidRequestException(\"Invalid path '\" + path + \"'.\");\n    }\n    return path;\n  }\n\n  private static short validateReplication(CacheDirectiveInfo directive,\n      short defaultValue) throws InvalidRequestException {\n    short repl = (directive.getReplication() != null)\n        ? directive.getReplication() : defaultValue;\n    if (repl <= 0) {\n      throw new InvalidRequestException(\"Invalid replication factor \" + repl\n          + \" <= 0\");\n    }\n    return repl;\n  }\n\n  /**\n   * Calculates the absolute expiry time of the directive from the\n   * {@link CacheDirectiveInfo.Expiration}. This converts a relative Expiration\n   * into an absolute time based on the local clock.\n   * \n   * @param info to validate.\n   * @param maxRelativeExpiryTime of the info's pool.\n   * @return the expiration time, or the pool's max absolute expiration if the\n   *         info's expiration was not set.\n   * @throws InvalidRequestException if the info's Expiration is invalid.\n   */\n  private static long validateExpiryTime(CacheDirectiveInfo info,\n      long maxRelativeExpiryTime) throws InvalidRequestException {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java#L377-L413","documentation":"Error \"Invalid replication factor {repl} <= 0\" thrown in apache/hadoop.","triggerScenarios":"addCacheDirective with a replication factor of zero or negative.","commonSituations":"See trigger scenarios.","solutions":["Set the cache directive replication factor to a positive integer."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}