{"record":{"id":"688637e064c236c2","repo":"aeron-io/aeron","slug":"label-length-exceeds-max-label-length-label-length","errorCode":null,"errorMessage":"label length exceeds MAX_LABEL_LENGTH: <label.length()>","messagePattern":"label length exceeds MAX_LABEL_LENGTH: <label\\.length\\(\\)>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ClientConductor.java","lineNumber":1165,"sourceCode":"            return (Counter)resourceByRegIdMap.get(registrationId);\n        }\n        finally\n        {\n            clientLock.unlock();\n        }\n    }\n\n    Counter addCounter(final int typeId, final String label)\n    {\n        clientLock.lock();\n        try\n        {\n            ensureActive();\n            ensureNotReentrant();\n\n            if (label.length() > CountersManager.MAX_LABEL_LENGTH)\n            {\n                throw new IllegalArgumentException(\"label length exceeds MAX_LABEL_LENGTH: \" + label.length());\n            }\n\n            final long registrationId = driverProxy.addCounter(typeId, label);\n            awaitResponse(registrationId);\n\n            return (Counter)resourceByRegIdMap.get(registrationId);\n        }\n        finally\n        {\n            clientLock.unlock();\n        }\n    }\n\n    Counter addStaticCounter(\n        final int typeId,\n        final DirectBuffer keyBuffer,\n        final int keyOffset,\n        final int keyLength,","sourceCodeStart":1147,"sourceCodeEnd":1183,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ClientConductor.java#L1147-L1183","documentation":"Thrown by ClientConductor's String-based addCounter overload when label.length() exceeds CountersManager.MAX_LABEL_LENGTH. Unlike the buffer overload this checks only the upper bound, since a String length cannot be negative.","triggerScenarios":"Calling addCounter(typeId, String label) with a label longer than CountersManager.MAX_LABEL_LENGTH (default 1024 characters).","commonSituations":"Labels embedding full channel URIs, session lists, or timestamps plus context; i18n strings longer than ASCII-size assumptions; telemetry systems auto-generating descriptive labels.","solutions":["Truncate the label: label.length() > CountersManager.MAX_LABEL_LENGTH ? label.substring(0, MAX_LABEL_LENGTH) : label.","Use an abbreviated label and put the details in the counter key or external metadata.","Enforce a label length limit where labels are constructed."],"exampleFix":"// before\nclient.addCounter(typeId, detailedLabel); // throws when > 1024 chars\n// after\nString label = detailedLabel.length() > CountersManager.MAX_LABEL_LENGTH\n    ? detailedLabel.substring(0, CountersManager.MAX_LABEL_LENGTH)\n    : detailedLabel;\nclient.addCounter(typeId, label);","handlingStrategy":"validation","validationCode":"if (label.length() > CountersManager.MAX_LABEL_LENGTH) label = label.substring(0, CountersManager.MAX_LABEL_LENGTH);\nclient.addCounter(typeId, label);","typeGuard":null,"tryCatchPattern":"try { client.addCounter(typeId, label); } catch (IllegalArgumentException e) { log.error(\"counter label too long: {}\", e.getMessage()); }","preventionTips":["Truncate String labels defensively before every addCounter call.","Put detailed context in the counter key instead of the label.","Add a length assertion in your counter factory method."],"tags":["java","aeron","counters","bounds"],"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-16T04:17:20.429Z"}