pinpoint-apm/pinpoint · error · IllegalStateException
unknown MethodType:${code}
Error message
unknown MethodType:${code} What it means
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.
Source
Thrown at commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/MethodTypeEnum.java:64
// corrupted when : 1. slow network, 2. too much node ...
CORRUPTED(MethodType.CORRUPTED);
private final int code;
MethodTypeEnum(int code) {
this.code = code;
}
public int getCode() {
return this.code;
}
public static MethodTypeEnum valueOf(int code) {
MethodTypeEnum methodTypeEnum = getMethodTypeEnum(code);
if (methodTypeEnum == null) {
throw new IllegalStateException("unknown MethodType:" + code);
}
return methodTypeEnum;
}
private static @Nullable MethodTypeEnum getMethodTypeEnum(int code) {
return switch (code) {
case MethodType.DEFAULT -> DEFAULT;
case MethodType.EXCEPTION -> EXCEPTION;
case MethodType.ANNOTATION -> ANNOTATION;
case MethodType.PARAMETER -> PARAMETER;
case MethodType.WEB_REQUEST -> WEB_REQUEST;
case MethodType.INVOCATION -> INVOCATION;
case MethodType.CORRUPTED -> CORRUPTED;
default -> null;
};
}
public static MethodTypeEnum defaultValueOf(int code) {View on GitHub (pinned to 744c3d3075)
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
Example fix
// before
MethodTypeEnum type = MethodTypeEnum.valueOf(code); // throws
// after
MethodTypeEnum type = MethodTypeEnum.getMethodTypeEnum(code);
if (type == null) { log.warn("unknown MethodType {}", code); type = MethodTypeEnum.DEFAULT; } Defensive patterns
Strategy: validation
Validate before calling
MethodTypeEnum t = MethodTypeEnum.getMethodTypeEnum(code); if (t == null) { log.warn("unknown MethodType {}", code); return; } Try / catch
try { return MethodTypeEnum.valueOf(code); } catch (IllegalStateException e) { log.warn("{}", e.getMessage()); return MethodTypeEnum.UNKNOWN; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown AgentType:
- list size not same
- Unknown SpanSenderType: ${value}
- unsupported message
- unsupported DataType:${dataType}
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/78ac91d309fe2db2.
Report an issue: GitHub.