Skip to Content

Errors

Every failure throws, or rejects with, a JavaScript Error whose code names it.

  • OT_<CODE>: a failure of the core. code is OT_ followed by the core’s stable code, message is the core’s human-readable text, and legacyMessage is the message of the matching Python exception; an OT_ error without one, such as an SRP refusal, repeats message there.
  • ERR_INVALID_ARG_VALUE: an argument the binding rejects before the core sees it, such as an unknown client name or a wrongly typed patch; it has no legacyMessage.
errors.mjs
import { loadTdata } from 'opentele2' try { await loadTdata('tdata', 'wrong passcode') } catch (error) { if (error.code === 'OT_TDATA_BAD_DECRYPT_KEY') console.log('wrong or missing passcode') else if (error.code === 'OT_TFILE_NOT_FOUND') console.log(error.legacyMessage) // Could not open key_data else throw error }

code values are stable across releases; message may change, so match on code. Each row below names the exception the Python package raises for the same failure.

Core codes

codeRaised when
OT_TFILE_NOT_FOUNDA required tdata file or .session file does not exist. Python: TFileNotFound.
OT_TDATA_INVALID_MAGICA tdata file does not start with TDF$, or the MTP data holds an unknown block. Python: TDataInvalidMagic.
OT_TDATA_INVALID_CHECKSUMA tdata file’s MD5 checksum does not match its contents. Python: TDataInvalidCheckSum.
OT_TDATA_BAD_DECRYPT_KEYDecryption does not match its key: the passcode is missing or wrong. Python: TDataBadDecryptKey.
OT_TDATA_WRONG_PASSCODEThe local passcode does not unlock the folder. Python: TDataWrongPasscode.
OT_TDATA_BAD_ENCRYPTED_DATA_SIZEEncrypted data has a size AES-IGE cannot take. Python: TDataBadEncryptedDataSize.
OT_TDATA_BAD_DECRYPTED_DATA_SIZEDecrypted data declares a size that does not fit. Python: TDataBadDecryptedDataSize.
OT_TDATA_BAD_CONFIG_DATAAn MTP config, endpoint or session row does not parse, or the main DC has no endpoint. Python: TDataBadConfigData.
OT_QDATASTREAM_FAILEDA Qt data stream read failed, or a .session file has another layout or version. Python: QDataStreamFailed.
OT_TDATA_READ_MAP_DATA_FAILEDAn account’s maps file cannot be read. Python: TDataReadMapDataFailed.
OT_TDATA_READ_MAP_DATA_INCORRECT_PASSCODEAn account’s map was read with a wrong passcode. Python: TDataReadMapDataIncorrectPasscode.
OT_TDATA_AUTH_KEY_NOT_FOUNDNo auth key for the main DC, or no row or key in a .session file. Python: TDataAuthKeyNotFound.
OT_MAX_ACCOUNT_LIMITA folder would hold more accounts than it may. Python: MaxAccountLimit.
OT_TDATA_SAVE_FAILEDSaving failed: no accounts, duplicate indices or an empty key file name. Python: TDataSaveFailed.
OT_TDATA_KEY_DATA_INVALIDThe key file is malformed or its passcode wrap parameters are unusable. Python: TDataKeyDataInvalid.
OT_BAD_LENGTHA buffer, key or IV has the wrong length. Python: ValueError.
OT_INVALID_INPUTAn argument is outside what the operation accepts. Python: ValueError.
OT_IOA file operation failed, or data is not what it should be (gzip, session JSON). Python: OSError.

Flow and SRP codes

The client flows of opentele2/mtcute and srpCheck fail with these; the name of a flow error is its Python exception class.

codeRaised when
OT_NO_PASSWORD_PROVIDEDA QR login met 2FA without a password. Python: NoPasswordProvided.
OT_PASSWORD_INCORRECTauth.checkPassword failed with PASSWORD_HASH_INVALID. Python: PasswordIncorrect.
OT_AUTH_TOKEN_ALREADY_ACCEPTEDThe QR login token was accepted already. Python: AuthTokenAlreadyAcceptedError.
OT_AUTH_TOKEN_EXPIREDThe QR login token expired. Python: AuthTokenExpiredError.
OT_AUTH_TOKEN_INVALIDThe QR login token is invalid. Python: AuthTokenInvalidError.
OT_QR_LOGIN_TIMEOUTNo QR login attempt logged in. Python: TimeoutError.
OT_FRESH_RESET_FORBIDDENA session cannot be terminated within 24 hours of login. Python: FreshResetAuthorisationForbiddenError.
OT_HASH_INVALIDterminateSession was given an unknown hash. Python: HashInvalidError.
OT_UNSUPPORTED_PASSWORD_ALGORITHMThe 2FA password uses an algorithm other than SRP_ALGORITHM. Python: ValueError.
OT_SIGN_UP_REQUIREDThe server asked to sign up instead of logging in. Python: SignUpRequired.
OT_USER_ID_UNRESOLVEDThe self user of a client cannot be resolved. Python: TelethonUnauthorized.
OT_SESSIONS_UNAVAILABLEThe account’s sessions cannot be fetched. Python: OpenTeleException.
OT_SRP_BAD_PRIME_OR_GENERATORThe 2FA p or g is not acceptable. Python: ValueError.
OT_SRP_BAD_BThe server’s srpB is out of range or missing. Python: ValueError.
OT_SRP_NO_GOOD_RANDOMEvery random draw for the SRP exponent was unusable. Python: ValueError.
OT_SRP_RANDOM_UNAVAILABLEThe OS random source failed during the SRP check. Python: ValueError.
index.d.ts
function flowErrorClasses(): Record<string, string>

flowErrorClasses() returns the Python class name of every flow and SRP code above, by OT_ code.

Last updated on