{"record":{"id":"6701b12909fe22e1","repo":"aeron-io/aeron","slug":"term-length-more-than-max-length-of-term-max-length-value","errorCode":null,"errorMessage":"term length more than max length of ${TERM_MAX_LENGTH}: value=${value}","messagePattern":"term length more than max length of (.+?): value=(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java","lineNumber":700,"sourceCode":"     *\n     * @param channelUri to read the value from.\n     * @return this for a fluent API.\n     * @see CommonContext#TERM_LENGTH_PARAM_NAME\n     */\n    public ChannelUriStringBuilder termLength(final ChannelUri channelUri)\n    {\n        final String termLengthValue = channelUri.get(TERM_LENGTH_PARAM_NAME);\n        if (null == termLengthValue)\n        {\n            termLength = null;\n            return this;\n        }\n        else\n        {\n            final long value = parseSize(TERM_LENGTH_PARAM_NAME, termLengthValue);\n            if (value > Integer.MAX_VALUE)\n            {\n                throw new IllegalArgumentException(\n                    \"term length more than max length of \" + TERM_MAX_LENGTH + \": value=\" + value);\n            }\n\n            return termLength((int)value);\n        }\n    }\n\n    /**\n     * Get the length of buffer used for each term of the log.\n     *\n     * @return the length of buffer used for each term of the log.\n     * @see CommonContext#TERM_LENGTH_PARAM_NAME\n     */\n    public Integer termLength()\n    {\n        return termLength;\n    }\n","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java#L682-L718","documentation":"ChannelUriStringBuilder.termLength(String) parses the 'term-length' URI parameter and throws IllegalArgumentException when the parsed size exceeds TERM_MAX_LENGTH (1GB, Integer.MAX_VALUE). Aeron term buffers are indexed by int, so a term length above 2^31-1 cannot be represented. The throw is a fail-fast guard preventing an impossible buffer size from reaching the media driver.","triggerScenarios":"Calling termLength(String) with a value string that parses to more than 1073741824 (1g), e.g. ChannelUri.addStaticId-style URIs containing term-length=2g, or calling the String overload instead of the Integer overload with an oversized value.","commonSituations":"Hand-written Aeron channel URIs with a mistaken 'g' suffix or unit (term-length=2g instead of 1g); copying channel configs between systems where a larger term length was used; typos where bytes were intended but a multiple-of-GB value was written.","solutions":["Reduce the term-length value in the URI to at most 1g (1073741824); use 1g if you need the maximum","Check for unit typos: '2g' should likely be '1g', '64m', etc.","Call the Integer/int overload termLength(int) so the compiler rejects out-of-range values at compile time where possible"],"exampleFix":"// before\nbuilder.termLength(\"2g\"); // throws\n// after\nbuilder.termLength(\"1g\"); // max allowed","handlingStrategy":"validation","validationCode":"long value = parseSize(\"term-length\", termLengthValue);\nif (value > Integer.MAX_VALUE) throw new IllegalArgumentException(\"term-length must be <= 1g: \" + value);","typeGuard":null,"tryCatchPattern":"try { builder.termLength(str); } catch (IllegalArgumentException e) { log.error(\"bad term-length: {}\", e.getMessage()); }","preventionTips":["Keep term lengths at or below 1g; prefer power-of-two values like 64m, 256m","Use the Integer overload termLength(int) to catch mistakes at compile time","Add unit tests asserting your configured URIs build successfully"],"tags":["aeron","uri-validation","argument-out-of-range"],"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"}