{"record":{"id":"de6318e0abec499e","repo":"apache/incubator-seata","slug":"unknown-codec-s","errorCode":null,"errorMessage":"unknown codec:%s","messagePattern":"unknown codec:(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/seata/core/serializer/SerializerType.java","lineNumber":99,"sourceCode":"    }\n\n    /**\n     * Gets result code.\n     *\n     * @param code the code\n     * @return the result code\n     */\n    public static SerializerType getByCode(int code) {\n        for (SerializerType b : SerializerType.values()) {\n            if (code == b.code) {\n                return b;\n            }\n        }\n        if (code == SerializerType.FST.getCode()) {\n            throw new IllegalArgumentException(\n                    \"Since fst is no longer maintained, this serialization extension has been removed from version 2.0 for security and stability reasons.\");\n        }\n        throw new IllegalArgumentException(\"unknown codec:\" + code);\n    }\n\n    /**\n     * Gets result code.\n     *\n     * @param name the name\n     * @return the result code\n     */\n    public static SerializerType getByName(String name) {\n        for (SerializerType b : SerializerType.values()) {\n            if (b.name().equalsIgnoreCase(name)) {\n                return b;\n            }\n        }\n        throw new IllegalArgumentException(\"unknown codec:\" + name);\n    }\n\n    /**","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/core/src/main/java/org/apache/seata/core/serializer/SerializerType.java#L81-L117","documentation":"The fallback of SerializerType.getByCode(int): the numeric codec id from a message header or config does not equal any SerializerType enum code, and it is not the legacy FST code either, so an IllegalArgumentException 'unknown codec:<code>' is thrown. The number itself is echoed in the message to identify the bad value.","triggerScenarios":"Decoding an inbound RPC frame whose codec byte is garbage (corrupt/truncated frame, non-Seata traffic hitting the port) or from a peer using a codec id your Seata build does not know; also programmatically calling SerializerType.getByCode with an arbitrary/wrong integer.","commonSituations":"A load balancer / health checker sending plain HTTP or TCP probes to the Seata service port so the first bytes are parsed as a codec id; version skew where a newer peer uses a newly-added codec id; byte-order/corruption bugs in custom proxies; hand-rolled calls passing config values as ints.","solutions":["Identify the code in the message and check which Seata version defines it; upgrade the peer that produced frames with that codec id.","If external probes hit the Seata port, move them to a different port or make them send valid Seata frames.","For custom integrations, validate the id against SerializerType values before calling getByCode (see validation below).","Capture the offending frame bytes if corruption is suspected (custom proxy, MTU/fragmentation issues)."],"exampleFix":"// before\nSerializerType type = SerializerType.getByCode(frame.readByte()); // probe/corruption -> unknown codec:72\n\n// after\nint code = frame.readByte();\nboolean known = Arrays.stream(SerializerType.values()).anyMatch(t -> t.getCode() == code);\nif (!known) {\n    throw new CorruptedFrameException(\"unsupported codec id: \" + code);\n}\nSerializerType type = SerializerType.getByCode(code);","handlingStrategy":"type-guard","validationCode":"int code = frame.readByte();\nif (!isKnownCodec(code)) {\n    throw new io.netty.handler.codec.CorruptedFrameException(\"unknown codec id: \" + code);\n}\nSerializerType type = SerializerType.getByCode(code);","typeGuard":"static boolean isKnownCodec(int code) {\n    for (SerializerType t : SerializerType.values()) {\n        if (t.getCode() == code) return true;\n    }\n    return false;\n}","tryCatchPattern":"try {\n    SerializerType t = SerializerType.getByCode(code);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"unknown codec:\")) {\n        // corrupt or foreign frame: drop the connection, never retry the same bytes\n        ctx.close();\n        return;\n    }\n    throw e;\n}","preventionTips":["Keep health checks / LB probes off the Seata RPC port.","Validate codec ids against the enum before calling getByCode in custom protocol glue.","Pin client and server versions so both sides know the same codec ids."],"tags":["serialization","protocol","decode","version-skew","corruption"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}