{"record":{"id":"2593c601d6aef3a4","repo":"aeron-io/aeron","slug":"generic-error","errorCode":"GENERIC_ERROR","errorMessage":"Invalidation reason must be ${MAX_ERROR_MESSAGE_LENGTH} bytes or less","messagePattern":"Invalidation reason must be (.+?) bytes or less","errorType":"error_code","errorClass":"ControlProtocolException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java","lineNumber":1100,"sourceCode":"    }\n\n    void onTerminateDriver(final DirectBuffer tokenBuffer, final int tokenOffset, final int tokenLength)\n    {\n        if (ctx.terminationValidator().allowTermination(ctx.aeronDirectory(), tokenBuffer, tokenOffset, tokenLength))\n        {\n            ctx.terminationHook().run();\n        }\n    }\n\n    void onRejectImage(\n        final long correlationId,\n        final long imageCorrelationId,\n        final long position,\n        final String reason)\n    {\n        if (reason.length() > ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH)\n        {\n            throw new ControlProtocolException(GENERIC_ERROR, \"Invalidation reason must be \" +\n                ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH + \" bytes or less\");\n        }\n\n        final PublicationImage publicationImage = findPublicationImage(imageCorrelationId);\n\n        if (null == publicationImage)\n        {\n            final IpcPublication foundPublication = getIpcPublication(imageCorrelationId);\n\n            if (null == foundPublication)\n            {\n                throw new ControlProtocolException(\n                    GENERIC_ERROR, \"Unable to resolve image for correlationId=\" + imageCorrelationId);\n            }\n\n            foundPublication.reject(position, reason, this, cachedNanoClock.nanoTime());\n        }\n        else","sourceCodeStart":1082,"sourceCodeEnd":1118,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java#L1082-L1118","documentation":"Thrown by the driver conductor when processing an image rejection request (onRejectImage) whose reason string exceeds ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH (max bytes an error message can occupy in the control protocol flyweight). The rejection reason travels inside a fixed-size control message buffer, so an oversized reason cannot be encoded and the request is rejected with a ControlProtocolException of code GENERIC_ERROR. This is a caller-side input validation failure, not an internal driver fault.","triggerScenarios":"Calling Aeron.rejectImage(correlationId, position, reason) (via Aeron client or Subscription#rejectImage) with a reason string longer than ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH bytes; the driver throws before looking up the image.","commonSituations":"Applications building rejection reasons dynamically by concatenating diagnostics, stack traces, or long URIs; embedding user-supplied text as the reason; missing truncation when adapting legacy logging messages to rejectImage API introduced in newer Aeron versions.","solutions":["Truncate the reason string to ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH bytes before calling rejectImage","Log the full diagnostics separately and pass a short fixed reason such as \"rejected by application policy\"","Check reason.length() client-side in a helper wrapper around rejectImage that clips to the limit","Upgrade/downgrade client and driver together so both agree on the message length limit"],"exampleFix":"// before\nsubscription.rejectImage(image.correlationId(), image.position(), \"Rejected: \" + detailedDiagnostics);\n// after\nString reason = \"Rejected: \" + detailedDiagnostics;\nif (reason.length() > ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH)\n{\n    reason = reason.substring(0, ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH);\n}\nsubscription.rejectImage(image.correlationId(), image.position(), reason);","handlingStrategy":"validation","validationCode":"if (reason == null || reason.length() > ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH)\n{\n    reason = reason != null ? reason.substring(0, ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH) : \"rejected\";\n}\nsubscription.rejectImage(imageCorrelationId, position, reason);","typeGuard":"static boolean isValidReason(String reason)\n{\n    return reason != null && reason.length() <= ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH;\n}","tryCatchPattern":"try\n{\n    subscription.rejectImage(id, position, reason);\n}\ncatch (ControlProtocolException ex)\n{\n    log.warn(\"rejectImage rejected: \" + ex.getMessage());\n}","preventionTips":["Clip reason strings to ErrorFlyweight.MAX_ERROR_MESSAGE_LENGTH before every rejectImage call","Keep rejection reasons short and static; put detail in application logs","Wrap rejectImage in a helper that enforces the limit"],"tags":["aeron","control-protocol","input-validation"],"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"}