{"record":{"id":"78ac91d309fe2db2","repo":"pinpoint-apm/pinpoint","slug":"unknown-methodtype-code","errorCode":null,"errorMessage":"unknown MethodType:${code}","messagePattern":"unknown MethodType:(.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/MethodTypeEnum.java","lineNumber":64,"sourceCode":"\n    // corrupted when : 1. slow network, 2. too much node ...\n    CORRUPTED(MethodType.CORRUPTED);\n\n    private final int code;\n\n\n    MethodTypeEnum(int code) {\n        this.code = code;\n    }\n\n    public int getCode() {\n        return this.code;\n    }\n\n    public static MethodTypeEnum valueOf(int code) {\n        MethodTypeEnum methodTypeEnum = getMethodTypeEnum(code);\n        if (methodTypeEnum == null) {\n            throw new IllegalStateException(\"unknown MethodType:\" + code);\n        }\n        return methodTypeEnum;\n    }\n\n    private static @Nullable MethodTypeEnum getMethodTypeEnum(int code) {\n        return switch (code) {\n            case MethodType.DEFAULT -> DEFAULT;\n            case MethodType.EXCEPTION -> EXCEPTION;\n            case MethodType.ANNOTATION -> ANNOTATION;\n            case MethodType.PARAMETER -> PARAMETER;\n            case MethodType.WEB_REQUEST -> WEB_REQUEST;\n            case MethodType.INVOCATION -> INVOCATION;\n            case MethodType.CORRUPTED -> CORRUPTED;\n            default -> null;\n        };\n    }\n\n    public static MethodTypeEnum defaultValueOf(int code) {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/MethodTypeEnum.java#L46-L82","documentation":"MethodTypeEnum.valueOf(int code) converts a numeric method-type code into the enum and throws IllegalStateException when no enum constant matches. It exists to reject unknown/corrupt method type codes read from span data rather than silently returning null.","triggerScenarios":"Calling MethodTypeEnum.valueOf(code) with an integer not registered in getMethodTypeEnum's switch — e.g. codes introduced by newer agents or garbage read from storage.","commonSituations":"Version skew between agent and server enum definitions; corrupt span payloads; hard-coded numeric codes in custom code that do not match the enum table.","solutions":["Use getMethodTypeEnum(code) and handle the null case instead of valueOf when the code is untrusted","Update commons-server so the enum covers the code being read","Check where the code originates (serialization offset, test constant) and fix the source","Log the code and fall back to a default/UNKNOWN handling in the caller"],"exampleFix":"// before\nMethodTypeEnum type = MethodTypeEnum.valueOf(code); // throws\n// after\nMethodTypeEnum type = MethodTypeEnum.getMethodTypeEnum(code);\nif (type == null) { log.warn(\"unknown MethodType {}\", code); type = MethodTypeEnum.DEFAULT; }","handlingStrategy":"validation","validationCode":"MethodTypeEnum t = MethodTypeEnum.getMethodTypeEnum(code); if (t == null) { log.warn(\"unknown MethodType {}\", code); return; }","typeGuard":null,"tryCatchPattern":"try { return MethodTypeEnum.valueOf(code); } catch (IllegalStateException e) { log.warn(\"{}\", e.getMessage()); return MethodTypeEnum.UNKNOWN; }","preventionTips":["Prefer getMethodTypeEnum with null handling for untrusted codes","Keep enum tables synchronized across agent/server versions","Never hard-code numeric method-type constants in client code"],"tags":["java","enum","deserialization","span"],"backgroundTag":"invalid-enum-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}