{"record":{"id":"8f2153f90ca39f64","repo":"apache/hadoop","slug":"can-t-have-more-than-in-an-addcloseop","errorCode":null,"errorMessage":"Can't have more than {} in an AddCloseOp.","messagePattern":"Can't have more than (.+?) in an AddCloseOp\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java","lineNumber":511,"sourceCode":"\n    <T extends AddCloseOp> T setModificationTime(long mtime) {\n      this.mtime = mtime;\n      return (T)this;\n    }\n\n    <T extends AddCloseOp> T setAccessTime(long atime) {\n      this.atime = atime;\n      return (T)this;\n    }\n\n    <T extends AddCloseOp> T setBlockSize(long blockSize) {\n      this.blockSize = blockSize;\n      return (T)this;\n    }\n\n    <T extends AddCloseOp> T setBlocks(Block[] blocks) {\n      if (blocks.length > MAX_BLOCKS) {\n        throw new RuntimeException(\"Can't have more than \" + MAX_BLOCKS +\n            \" in an AddCloseOp.\");\n      }\n      this.blocks = FSEditLogOp.deepCopy(blocks);\n      return (T)this;\n    }\n    \n    @Override\n    public Block[] getBlocks() {\n      return blocks;\n    }\n\n    <T extends AddCloseOp> T setPermissionStatus(PermissionStatus permissions) {\n      this.permissions = permissions;\n      return (T)this;\n    }\n\n    <T extends AddCloseOp> T setAclEntries(List<AclEntry> aclEntries) {\n      this.aclEntries = aclEntries;","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L493-L529","documentation":"AddCloseOp.setBlocks rejects block arrays longer than MAX_BLOCKS (1024*1024*64 = 67108864) with a RuntimeException. This is a writer-side sanity bound while constructing the edit op. A real file cannot reach that many blocks, so hitting it means programmatic misuse (building ops by hand) or corrupted upstream state.","triggerScenarios":"Calling setBlocks on an AddCloseOp (or its subclasses in log-generation code and tests) with an array larger than 64Mi entries; synthesizing ops from state where a bogus block count produced an oversized array.","commonSituations":"Unit tests and tooling that construct synthetic edit ops; log fuzzers feeding random block counts.","solutions":["Check blocks.length against AddCloseOp.MAX_BLOCKS before calling setBlocks","If state claims that many blocks for one file, treat the state as corrupt and investigate the writer","Split or shrink synthetic test data so each op stays under the bound"],"exampleFix":"// before\nop.setBlocks(file.getBlocks());   // RuntimeException if over MAX_BLOCKS\n\n// after\nBlock[] blocks = file.getBlocks();\nif (blocks.length > AddCloseOp.MAX_BLOCKS) {\n  throw new IllegalArgumentException(\"File has \" + blocks.length\n      + \" blocks; AddCloseOp supports at most \" + AddCloseOp.MAX_BLOCKS);\n}\nop.setBlocks(blocks);","handlingStrategy":"validation","validationCode":"Block[] blocks = file.getBlocks();\nPreconditions.checkArgument(blocks.length <= FSEditLogOp.AddCloseOp.MAX_BLOCKS,\n    \"File carries %s blocks; AddCloseOp supports at most %s\",\n    blocks.length, FSEditLogOp.AddCloseOp.MAX_BLOCKS);\nop.setBlocks(blocks);","typeGuard":null,"tryCatchPattern":"try {\n  op.setBlocks(blocks);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"MAX_BLOCKS\")) {\n    // synthetic data exceeded the 64M-block bound: shrink the input,\n    // the limit itself is correct\n  }\n  throw e;\n}","preventionTips":["Assert block counts in tests that synthesize edit ops","Never feed unvalidated external state into op builders"],"tags":["hdfs","namenode","edit-log","add-close-op","max-blocks","validation"],"backgroundTag":"payload-size-limit-exceeded","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}