{"record":{"id":"27f36acb565424ec","repo":"apache/hadoop","slug":"invalid-negative-id","errorCode":null,"errorMessage":"Invalid negative ID.","messagePattern":"Invalid negative ID\\.","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":519,"sourceCode":"        if (child.isFile()) {\n          requestedBytes += child.asFile().computeFileSize();\n        }\n      }\n    }\n    return new CacheDirectiveStats.Builder()\n        .setBytesNeeded(requestedBytes * replication)\n        .setFilesCached(requestedFiles)\n        .build();\n  }\n\n  /**\n   * Get a CacheDirective by ID, validating the ID and that the directive\n   * exists.\n   */\n  private CacheDirective getById(long id) throws InvalidRequestException {\n    // Check for invalid IDs.\n    if (id <= 0) {\n      throw new InvalidRequestException(\"Invalid negative ID.\");\n    }\n    // Find the directive.\n    CacheDirective directive = directivesById.get(id);\n    if (directive == null) {\n      throw new InvalidRequestException(\"No directive with ID \" + id\n          + \" found.\");\n    }\n    return directive;\n  }\n\n  /**\n   * Get a CachePool by name, validating that it exists.\n   */\n  private CachePool getCachePool(String poolName)\n      throws InvalidRequestException {\n    CachePool pool = cachePools.get(poolName);\n    if (pool == null) {\n      throw new InvalidRequestException(\"Unknown pool \" + poolName);","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java#L501-L537","documentation":"Error \"Invalid negative ID.\" thrown in apache/hadoop.","triggerScenarios":"modifyCacheDirective with a negative directive ID.","commonSituations":"See trigger scenarios.","solutions":["Use a positive cache directive ID returned by hdfs cacheadmin -listDirectives."],"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"}