{"record":{"id":"2448e7609772fff8","repo":"aeron-io/aeron","slug":"invalid-fragmentcountlimit-fragmentcountlimit","errorCode":null,"errorMessage":"Invalid fragmentCountLimit=\" + fragmentCountLimit","messagePattern":"Invalid fragmentCountLimit=\" \\+ fragmentCountLimit","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/ArchiveTool.java","lineNumber":543,"sourceCode":"\n    /**\n     * Dump the contents of an {@link Archive} so it can be inspected or debugged. Each recording will have its\n     * contents dumped up to fragmentCountLimit before requesting to continue.\n     *\n     * @param out                               to which the contents will be printed.\n     * @param archiveDir                        containing the {@link Archive}.\n     * @param fragmentCountLimit                limit of data fragments to print from each recording before continue.\n     * @param confirmActionOnFragmentCountLimit confirm continue to dump at limit.\n     */\n    public static void dump(\n        final PrintStream out,\n        final File archiveDir,\n        final long fragmentCountLimit,\n        final ActionConfirmation<Long> confirmActionOnFragmentCountLimit)\n    {\n        if (fragmentCountLimit <= 0)\n        {\n            throw new IllegalArgumentException(\"Invalid fragmentCountLimit=\" + fragmentCountLimit);\n        }\n\n        try (Catalog catalog = openCatalogReadOnly(archiveDir, INSTANCE);\n            ArchiveMarkFile markFile = openMarkFile(archiveDir, out::println))\n        {\n            printMarkInformation(markFile, out);\n            out.println(\"Catalog capacity in bytes: \" + catalog.capacity());\n\n            out.println();\n            out.println(\"Dumping up to \" + fragmentCountLimit + \" fragments per recording\");\n\n            final SimpleFragmentHandler fragmentHandler = (buffer, offset, length, frameType, flags, reservedValue) ->\n            {\n                out.println(\"data at offset [\" + offset + \"] with length = \" + length);\n                if (HDR_TYPE_PAD == frameType)\n                {\n                    out.println(\"PADDING FRAME\");\n                }","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/ArchiveTool.java#L525-L561","documentation":"ArchiveTool.dump validates its fragmentCountLimit argument and throws IllegalArgumentException when it is <= 0. The limit controls how many fragments will be dumped per recording replay, so a non-positive value is meaningless. This is a caller-supplied argument validation error.","triggerScenarios":"Calling ArchiveTool.dump(archiveDir, fragmentCountLimit, confirmActionOnFragmentCountLimit) with fragmentCountLimit <= 0, e.g. passing a default-uninitialized 0 or a negative computed limit.","commonSituations":"Scripting the tool with a variable that defaulted to 0; off-by-one or sign error when computing the limit from user input; CLI parsing bug feeding -1.","solutions":["Pass a positive fragmentCountLimit (>= 1) to ArchiveTool.dump.","Clamp or default the value before calling, e.g. Math.max(1, limit).","Fix the CLI/input parsing that produced the non-positive value."],"exampleFix":"// before\nlong fragmentCountLimit = 0;\nArchiveTool.dump(archiveDir, fragmentCountLimit, confirm); // throws\n// after\nlong fragmentCountLimit = Math.max(1, parsedLimit);\nArchiveTool.dump(archiveDir, fragmentCountLimit, confirm);","handlingStrategy":"validation","validationCode":"if (fragmentCountLimit <= 0) {\n    throw new IllegalArgumentException(\"fragmentCountLimit must be > 0, got \" + fragmentCountLimit);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default the limit to a sane positive constant when input is missing.","Validate CLI-parsed numbers for sign before passing to ArchiveTool.dump.","Use Math.max(1, value) as a guard when the limit is computed."],"tags":["aeron","archive","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}