{"record":{"id":"55fa95f3565ef49a","repo":"aeron-io/aeron","slug":"padding-exceeds-maxframedlength-of-length","errorCode":null,"errorMessage":"padding exceeds maxFramedLength of , length=","messagePattern":"padding exceeds maxFramedLength of , length=","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ExclusivePublication.java","lineNumber":466,"sourceCode":"            }\n        }\n\n        return newPosition;\n    }\n\n    /**\n     * Append a padding record to log of a given length to make up the log to a position.\n     *\n     * @param length of the range to claim, in bytes.\n     * @return The new stream position, otherwise a negative error value of {@link #NOT_CONNECTED},\n     * {@link #BACK_PRESSURED}, {@link #ADMIN_ACTION}, {@link #CLOSED}, or {@link #MAX_POSITION_EXCEEDED}.\n     * @throws IllegalArgumentException if the length is greater than {@link #maxMessageLength() framed}.\n     */\n    public long appendPadding(final int length)\n    {\n        if (length > maxFramedLength)\n        {\n            throw new IllegalArgumentException(\n                \"padding exceeds maxFramedLength of \" + maxFramedLength + \", length=\" + length);\n        }\n\n        long newPosition = CLOSED;\n        if (!isClosed)\n        {\n            final long limit = positionLimit.getVolatile();\n            final long position = termBeginPosition + termOffset;\n\n            if (position < limit)\n            {\n                checkPositiveLength(length);\n                final int tailCounterOffset = TERM_TAIL_COUNTERS_OFFSET + (activePartitionIndex * SIZE_OF_LONG);\n                final UnsafeBuffer termBuffer = termBuffers[activePartitionIndex];\n                final int result = appendPadding(termBuffer, tailCounterOffset, length);\n\n                newPosition = newPosition(result);\n            }","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ExclusivePublication.java#L448-L484","documentation":"ExclusivePublication.appendPadding() throws this IllegalArgumentException when the requested padding length is greater than maxFramedLength(). Padding can only be written as a single framed message within a term, so lengths above the maximum framed size cannot be represented. Aeron throws eagerly to prevent writing an invalid frame.","triggerScenarios":"Calling ExclusivePublication.appendPadding(length) with length > publication.maxFramedLength() (which is termLength/2 minus header overhead). E.g. appendPadding on a publication with a small term length but a large padding request.","commonSituations":"Configuring a term buffer too small (e.g. default 64KB) while padding to align to large boundaries; computing padding size from a user-supplied or network-derived value without clamping; copying code tuned for larger term lengths to a channel with a different term-length setting.","solutions":["Clamp the requested padding to publication.maxFramedLength() before calling appendPadding.","Increase the channel's term-length (e.g. aeron.term.length=1m) so maxFramedLength covers the desired padding.","Split oversized padding across multiple appendPadding/offer calls or use a zero-filled message offer instead."],"exampleFix":"// before\npublication.appendPadding(paddingLength);\n// after\nif (paddingLength > publication.maxFramedLength()) {\n    paddingLength = publication.maxFramedLength();\n}\npublication.appendPadding(paddingLength);","handlingStrategy":"validation","validationCode":"if (paddingLength < 0 || paddingLength > publication.maxFramedLength()) {\n    throw new IllegalArgumentException(\"paddingLength must be <= \" + publication.maxFramedLength());\n}","typeGuard":null,"tryCatchPattern":"try {\n    publication.appendPadding(len);\n} catch (IllegalArgumentException e) {\n    // fall back to publication.offer(zeroFilledBuffer) or split padding\n}","preventionTips":["Always derive padding size from publication.maxFramedLength(), never a constant.","Set the channel term-length explicitly and large enough for your largest padding requirement.","Validate user/network-supplied padding lengths at the boundary before publishing."],"tags":["aeron","publication","argument-validation","message-length"],"backgroundTag":"value-out-of-range","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"}