egametang/ET · critical · Exception
OpcodeType not found type: {opcode}
Error message
OpcodeType not found type: {opcode} What it means
OpcodeType.GetType(ushort) reverses the opcode->Type map and throws when the opcode is unknown. This fires during deserialization when a numeric opcode arrives that has no registered message type, typically a protocol/version mismatch.
Source
Thrown at Packages/cn.etetet.core/Scripts/Core/Share/Network/OpcodeType.cs:74
}
}
public ushort GetOpcode(Type type)
{
ushort opcode = this.typeOpcode.GetValueByKey(type);
if (opcode == 0)
{
throw new Exception($"OpcodeType not found opcode: {type.FullName}");
}
return opcode;
}
public Type GetType(ushort opcode)
{
Type type = this.typeOpcode.GetKeyByValue(opcode);
if (type == null)
{
throw new Exception($"OpcodeType not found type: {opcode}");
}
return type;
}
public Type GetResponseType(Type request)
{
if (!this.requestResponse.TryGetValue(request, out Type response))
{
throw new Exception($"not found response type, request type: {request.FullName}");
}
return response;
}
}
}
View on GitHub (pinned to 5cab01f7a8)
Solutions
- Keep client and server protocol/opcode tables in sync (regenerate together).
- Drop/log unknown opcodes at the dispatch boundary instead of letting GetType throw.
- Verify protocol version on connect and reject mismatched peers.
Example fix
// before
Type t = OpcodeType.Instance.GetType(opcode);
// after
Type t = OpcodeType.Instance.TryGetType(opcode);
if (t == null) { Log.Warning($"unknown opcode {opcode}"); return; } Defensive patterns
Strategy: validation
Validate before calling
if (!OpcodeType.Instance.TryGetType(opcode, out Type t)) { Log.Warning($"unknown opcode {opcode}"); return; } Type guard
public bool TryGetType(ushort opcode, out Type t) { t = typeOpcode.GetKeyByValue(opcode); return t != null; } Try / catch
null
Prevention
- Keep client and server opcode tables generated from the same source.
- Drop/log unknown opcodes at dispatch instead of throwing.
- Version-check the protocol on connect.
When it happens
Trigger: Receiving a packet whose opcode is not in the local table, e.g. client and server built from different protocol versions, or an opcode injected by a scanner.
Common situations: Client/server out of sync after a protocol change, an old client hitting a new server, or malicious/garbage traffic.
Related errors
- OpcodeType not found opcode: {type.FullName}
- not found response type, request type: {request.FullName}
- 不支持导出 UnityEngine.Object 类型: {runtimeType.FullName}
- {runtimeType.FullName} 缺少可用于导出的公共构造函数。必须通过构造函数提供的成员: {names}
- 无法为类型 {type.FullName} 生成稳定排序键
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/bac2dde833640366.
Report an issue: GitHub.