{"record":{"id":"3ac28c7660ab32f3","repo":"aeron-io/aeron","slug":"einval-term-length-less-than-min-size-of-term-min-length","errorCode":"EINVAL","errorMessage":"term length less than min size of {TERM_MIN_LENGTH}, length={termLength}","messagePattern":"term length less than min size of (.+?), length=(.+?)","errorType":"exception","errorClass":"util::IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/cpp_wrapper/concurrent/logbuffer/LogBufferDescriptor.h","lineNumber":116,"sourceCode":" *  +---------------------------------------------------------------+\n *  |                         Term Length                           |\n *  +---------------------------------------------------------------+\n *  |                          Page Size                            |\n *  +---------------------------------------------------------------+\n *  |                      Cache Line Padding                      ...\n * ...                                                              |\n *  +---------------------------------------------------------------+\n *  |                    Default Frame Header                      ...\n * ...                                                              |\n *  +---------------------------------------------------------------+\n * </pre>\n */\n\ninline void checkTermLength(std::int32_t termLength)\n{\n    if (termLength < TERM_MIN_LENGTH)\n    {\n        throw util::IllegalStateException(\n            \"term length less than min size of \" + std::to_string(TERM_MIN_LENGTH) +\n            \", length=\" + std::to_string(termLength), SOURCEINFO, EINVAL);\n    }\n\n    if (termLength > TERM_MAX_LENGTH)\n    {\n        throw util::IllegalStateException(\n            \"term length greater than max size of \" + std::to_string(TERM_MAX_LENGTH) +\n            \", length=\" + std::to_string(termLength), SOURCEINFO, EINVAL);\n    }\n\n    if (!util::BitUtil::isPowerOfTwo(termLength))\n    {\n        throw util::IllegalStateException(\n            \"term length not a power of 2, length=\" + std::to_string(termLength), SOURCEINFO, EINVAL);\n    }\n}\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/cpp_wrapper/concurrent/logbuffer/LogBufferDescriptor.h#L98-L134","documentation":"LogBufferDescriptor::checkTermLength rejects term lengths below TERM_MIN_LENGTH (64KB) with IllegalStateException (EINVAL), because Aeron term buffers must be at least the minimum size to function correctly.","triggerScenarios":"Calling checkTermLength (directly or via ChannelUriStringBuilder when validating a termLength parameter) with a value < 64KB, e.g. setting 'termLength' on a ChannelUriStringBuilder to 4096.","commonSituations":"Setting an URI term-length option too small for low-latency testing (e.g. 16KB or 4KB); copying a term length from another messaging system with smaller defaults; typos like 64_000 instead of 65536 with small suffixes.","solutions":["Use a term length of at least 64KB (65536).","When building a channel URI, set termLength to a legal value: 65536, 131072, ... up to 1GB, power of two.","Clamp/normalize user-supplied term lengths before constructing the channel."],"exampleFix":"// before\nbuilder.termLength(16 * 1024);\n// after\nbuilder.termLength(64 * 1024);","handlingStrategy":"validation","validationCode":"if (termLength < LogBufferDescriptor::TERM_MIN_LENGTH) termLength = LogBufferDescriptor::TERM_MIN_LENGTH; // then build channel","typeGuard":null,"tryCatchPattern":"try { builder.termLength(termLength); } catch (const aeron::util::IllegalStateException& e) { builder.termLength(LogBufferDescriptor::TERM_MIN_LENGTH); }","preventionTips":["Clamp user-supplied term lengths to [64KB, 1GB] before building URIs","Use 1024-based units, never 1000-based, when sizing buffers","Centralize term-length parsing in one validated helper"],"tags":["aeron","configuration","logbuffer","term-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"}