Short answer: An address string was not 58 characters. It is raised when the transaction is encoded or signed, not when you construct it.
WrongKeyLengthError: key length must be 58
Source: captured locally with py-algorand-sdk 2.12.0 on 2026-12-03.
Captured with PaymentTxn(sender, sp, "NOTANADDRESS", 1): construction succeeded, and .sign(sk) raised the error. Building the transaction alone did not validate the receiver.
encoding.is_valid_address(addr).Wording can change between SDK versions. All Python SDK errors · errors.json · JavaScript SDK errors · API errors · node errors