{"id":"784de1ed29dc1886","repo":"sequelize/sequelize","slug":"unable-to-start-a-transaction-without-the-transact-784de1","errorCode":null,"errorMessage":"Unable to start a transaction without the transaction object.","messagePattern":"Unable to start a transaction without the transaction object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ibmi/src/query-interface.ts","lineNumber":31,"sourceCode":"\nexport class IBMiQueryInterface<\n  Dialect extends IBMiDialect = IBMiDialect,\n> extends AbstractQueryInterface<Dialect> {\n  readonly #internalQueryInterface: IBMiQueryInterfaceInternal;\n\n  constructor(dialect: Dialect, internalQueryInterface?: IBMiQueryInterfaceInternal) {\n    internalQueryInterface ??= new IBMiQueryInterfaceInternal(dialect);\n\n    super(dialect, internalQueryInterface);\n    this.#internalQueryInterface = internalQueryInterface;\n  }\n\n  async _startTransaction(\n    transaction: Transaction,\n    options: StartTransactionOptions,\n  ): Promise<void> {\n    if (!transaction || !(transaction instanceof Transaction)) {\n      throw new Error('Unable to start a transaction without the transaction object.');\n    }\n\n    if (options) {\n      rejectInvalidOptions(\n        'startTransactionQuery',\n        this.sequelize.dialect,\n        START_TRANSACTION_QUERY_SUPPORTABLE_OPTIONS,\n        this.sequelize.dialect.supports.startTransaction,\n        options,\n      );\n    }\n\n    const connection = transaction.getConnection() as IBMiConnection;\n    await connection.beginTransaction();\n    if (options.isolationLevel) {\n      await transaction.setIsolationLevel(options.isolationLevel);\n    }\n  }","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/sequelize/sequelize/blob/7e1deec499d5afbb8d1877c2f4d545cead1214ec/packages/ibmi/src/query-interface.ts#L13-L49","documentation":"Thrown by IBMiQueryInterface._startTransaction when the transaction argument is missing or not a Transaction instance. The start path needs the Transaction to obtain its ODBC connection and call connection.beginTransaction(), so a falsy/wrong-typed value is rejected.","triggerScenarios":"Internal invocation of _startTransaction with undefined/null or a non-Transaction value; typically only reached via a subclass, hook, or direct test usage.","commonSituations":"Subclassing QueryInterface incorrectly, calling the underscore method directly, or losing the Transaction handle in control flow.","solutions":["Use the public sequelize.transaction() API which constructs and forwards the Transaction correctly.","If invoking _startTransaction manually, pass the Transaction instance from the sequelize transaction manager.","Guard with instanceof Transaction before the call."],"exampleFix":"// before\nawait qi._startTransaction(null, {});\n// after\nawait sequelize.transaction(async t => {\n  // _startTransaction(t, options) called internally\n});","handlingStrategy":"type-guard","validationCode":"import { Transaction } from '@sequelize/core';\nif (!(transaction instanceof Transaction)) {\n  throw new Error('startTransaction requires a Transaction instance');\n}","typeGuard":"import { Transaction } from '@sequelize/core';\nfunction isTransaction(v) { return v instanceof Transaction; }","tryCatchPattern":null,"preventionTips":["Use sequelize.transaction(fn) over the internal _startTransaction method.","Obtain Transaction instances only through the sequelize transaction manager.","Never pass null/undefined as the transaction argument."],"tags":["ibmi","transactions","begin","internal"],"analyzedSha":"7e1deec499d5afbb8d1877c2f4d545cead1214ec","analyzedAt":"2026-08-03T18:58:44.549Z","schemaVersion":2}