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

  1. Keep client and server protocol/opcode tables in sync (regenerate together).
  2. Drop/log unknown opcodes at the dispatch boundary instead of letting GetType throw.
  3. 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

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


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/bac2dde833640366. Report an issue: GitHub.