{"record":{"id":"52e0594bd66d6b97","repo":"aeron-io/aeron","slug":"invalid-typecode-typecode","errorCode":null,"errorMessage":"Invalid typeCode=${typeCode}","messagePattern":"Invalid typeCode=(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/logging/EventCodeType.java","lineNumber":87,"sourceCode":"\n    /**\n     * Get the EventTypeCode based on the matching typeCode value.\n     *\n     * @param typeCode used to resolve the EventTypeCode.\n     * @return the resolved EventTypeCode.\n     * @throws IllegalArgumentException if the typeCode does not match one of the enum values.\n     */\n    public static EventCodeType get(final int typeCode)\n    {\n        return switch (typeCode)\n        {\n            case 0 -> DRIVER;\n            case 1 -> ARCHIVE;\n            case 2 -> CLUSTER;\n            case 3 -> STANDBY;\n            case 4 -> SEQUENCER;\n            case 0xFFFF -> USER;\n            default -> throw new IllegalArgumentException(\"Invalid typeCode=\" + typeCode);\n        };\n    }\n}\n","sourceCodeStart":69,"sourceCodeEnd":91,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/logging/EventCodeType.java#L69-L91","documentation":"EventCodeType.get maps a numeric typeCode to an EventCodeType enum constant (DRIVER=0, ARCHIVE=1, CLUSTER=2, STANDBY=3, SEQUENCER=4, USER=0xFFFF). An unknown code throws IllegalArgumentException('Invalid typeCode=...'), meaning the event log contains a type code this Aeron version does not recognize.","triggerScenarios":"Decoding an event log written by a newer Aeron version that introduced a new type code; passing a raw byte/int from user data as a type code; reading a corrupted header byte.","commonSituations":"Version mismatch between capture tooling and this library; manually constructed event headers with bad codes; forward-compatibility gaps after an Aeron upgrade.","solutions":["Upgrade to the Aeron version matching the one that produced the event log.","Log and skip records with unknown type codes instead of failing the whole decode.","Verify the type code is read from the correct header offset.","If adding a custom type, register it in the EventCodeType switch."],"exampleFix":"// before\nfinal EventCodeType type = EventCodeType.get(typeCode); // throws on unknown\n// after\ntry\n{\n    final EventCodeType type = EventCodeType.get(typeCode);\n}\ncatch (final IllegalArgumentException ex)\n{\n    LOGGER.warn(\"skipping unknown event typeCode=\" + typeCode);\n    return;\n}","handlingStrategy":"try-catch","validationCode":"static boolean isKnownTypeCode(final int typeCode)\n{\n    return typeCode >= 0 && typeCode <= 4 || typeCode == 0xFFFF;\n}","typeGuard":"boolean isValidEventCodeType(final int typeCode)\n{\n    return (typeCode >= 0 && typeCode <= 4) || typeCode == 0xFFFF;\n}","tryCatchPattern":"try\n{\n    final EventCodeType type = EventCodeType.get(typeCode);\n    // process record\n}\ncatch (final IllegalArgumentException ex)\n{\n    LOGGER.warn(\"unknown event typeCode=\" + typeCode + \", skipping record\");\n}","preventionTips":["Run capture and decode tooling from the same Aeron version.","Validate header bytes come from the correct offset.","Skip unknown type codes defensively to stay forward-compatible.","Upgrade Aeron when logs contain unrecognized codes."],"tags":["enum","decoding","version-compatibility"],"backgroundTag":"invalid-enum-value","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}