{"record":{"id":"6ec583f44476123e","repo":"stride3d/stride","slug":"there-is-no-transaction-in-progress-in-the-transaction-stack","errorCode":null,"errorMessage":"There is no transaction in progress in the transaction stack.","messagePattern":"There is no transaction in progress in the transaction stack\\.","errorType":"exception","errorClass":"TransactionException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Design/Transactions/TransactionStack.cs","lineNumber":98,"sourceCode":"            if ((flags & TransactionFlags.KeepParentsAlive) != 0)\n            {\n                foreach (var parentTransaction in transactionsInProgress)\n                    parentTransaction.AddReference();\n            }\n\n            transactionsInProgress.Push(transaction);\n            TransactionInProgress = true;\n            return transaction;\n        }\n    }\n\n    /// <inheritdoc/>\n    public void PushOperation(Operation operation)\n    {\n        lock (lockObject)\n        {\n            if (transactionsInProgress.Count == 0)\n                throw new TransactionException(\"There is no transaction in progress in the transaction stack.\");\n\n            if (!operation.HasEffect)\n                return;\n\n            var transaction = transactionsInProgress.Peek();\n            transaction.PushOperation(operation);\n        }\n    }\n\n    /// <inheritdoc/>\n    public void Clear()\n    {\n        lock (lockObject)\n        {\n            if (RollInProgress)\n                throw new TransactionException(\"Unable to clear. A rollback or rollforward operation is in progress.\");\n\n            foreach (var transaction in transactions)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Design/Transactions/TransactionStack.cs#L80-L116","documentation":"TransactionStack.PushOperation() requires an open transaction to attach the operation to. The stack throws this error when PushOperation is called while the transactionsInProgress stack is empty, meaning there is no active CreateTransaction context to push the operation onto. Operations must always be recorded inside a transaction scope.","triggerScenarios":"Calling transactionStack.PushOperation(operation) without a prior CreateTransaction()/PushTransaction() call, or after the enclosing transaction was already completed via EndTransaction.","commonSituations":"Deferred/async code that records undo operations after the transaction has ended; forgetting to open a transaction before mutating an object tracked by the stack; an exception path that ended the transaction early while deferred callbacks still fire.","solutions":["Open a transaction with CreateTransaction (or PushTransaction) before calling PushOperation.","Check TransactionStack.TransactionInProgress (or capture the transaction scope) before deferring PushOperation calls.","Restructure deferred code so all operations are recorded before EndTransaction is invoked.","Wrap PushOperation in try-catch on TransactionException as a last resort to ignore orphaned operations."],"exampleFix":"// before\ntransactionStack.PushOperation(operation);\n\n// after\nif (transactionStack.TransactionInProgress)\n    transactionStack.PushOperation(operation);","handlingStrategy":"validation","validationCode":"if (!transactionStack.TransactionInProgress)\n    throw new InvalidOperationException(\"No transaction in progress; call CreateTransaction before PushOperation.\");\ntransactionStack.PushOperation(operation);","typeGuard":"bool HasOpenTransaction(TransactionStack stack) => stack.TransactionInProgress;","tryCatchPattern":"try\n{\n    transactionStack.PushOperation(operation);\n}\ncatch (TransactionException ex) when (ex.Message.Contains(\"no transaction in progress\"))\n{\n    // log and drop the orphaned operation\n}","preventionTips":["Always open a transaction scope before recording operations.","Use a using/scope helper so begin/end are paired automatically.","Never defer PushOperation past the end of the transaction scope."],"tags":["transactions","undo-redo","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}