Skip to content

miniproto.invoke.decode_rpc_response

decode_rpc_response(raw_result: object, raw_request: object) -> object

Decode and validate an RPC result, translating Telegram error bodies.

Parameters:

  • raw_result (object) – Sender result, possibly encoded bytes or an MTProto error object.
  • raw_request (object) – Original request used to infer and validate its result type.

Returns:

  • object – The decoded result matching the request’s declared TL result type.

Raises:

  • RpcError – A classified Telegram RPC error when the result is an error body.
  • ResultTypeMismatch – If a non-generic decoded result disagrees with the request contract.
  • TLCodecError – If an encoded result is malformed or contains trailing bytes.