read_state_raw assumes decoded_obj["certificate"] is CBOR-encoded bytes, but some gateways return it as a hex str. This causes cbor2.loads(str) to fail with TypeError: string indices must be integers, not 'str'.
|
def read_state_raw(self, canister_id, paths): |
and
|
async def read_state_raw_async(self, canister_id, paths): |
Fix: Normalize the certificate value before the inner cbor2.loads:
cert_raw = decoded_obj["certificate"]
if isinstance(cert_raw, str):
cert_raw = bytes.fromhex(cert_raw)
cert_dict = cbor2.loads(cert_raw)
read_state_raw assumes decoded_obj["certificate"] is CBOR-encoded bytes, but some gateways return it as a hex str. This causes cbor2.loads(str) to fail with TypeError: string indices must be integers, not 'str'.
ic-py/ic/agent.py
Line 239 in 0e58fd1
and
ic-py/ic/agent.py
Line 262 in 0e58fd1
Fix: Normalize the certificate value before the inner cbor2.loads: