{"record":{"id":"01c84ed44318a877","repo":"stride3d/stride","slug":"there-is-not-transaction-in-progress-in-the-transaction","errorCode":null,"errorMessage":"There is not transaction in progress in the transaction stack.","messagePattern":"There is not 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":139,"sourceCode":"            currentPosition = 0;\n            Cleared?.Invoke(this, EventArgs.Empty);\n        }\n    }\n\n    /// <inheritdoc/>\n    public IEnumerable<IReadOnlyTransaction> RetrieveAllTransactions()\n    {\n        return transactions;\n    }\n\n    public void CompleteTransaction(Transaction transaction)\n    {\n        lock (lockObject)\n        {\n            try\n            {\n                if (transactionsInProgress.Count == 0)\n                    throw new TransactionException(\"There is not transaction in progress in the transaction stack.\");\n\n                if (transaction != transactionsInProgress.Pop())\n                    throw new TransactionException(\"The transaction being completed is not that last created transaction.\");\n\n                // Check if we're completing the last transaction\n                TransactionInProgress = transactionsInProgress.Count > 0;\n\n                // Ignore the transaction if it is empty\n                if (transaction.IsEmpty)\n                    return;\n\n                // If this transaction has no effect, discard it.\n                if (transaction.Operations.All(x => !x.HasEffect))\n                    return;\n\n                // If we're not the last transaction, consider this transaction as an operation of its parent transaction\n                if (TransactionInProgress)\n                {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Design/Transactions/TransactionStack.cs#L121-L157","documentation":"EndTransaction requires at least one transaction to be in progress; the transactionsInProgress stack must be non-empty so the passed transaction can be matched and popped. This error (note the typo 'not transaction' in the message) is thrown when EndTransaction is called with no transaction currently in progress.","triggerScenarios":"Calling transactionStack.EndTransaction(transaction) when no CreateTransaction/PushTransaction is open, or calling EndTransaction twice for the same transaction (the first call already popped it).","commonSituations":"Duplicate EndTransaction calls in exception-prone code paths; a finally block calling EndTransaction when the transaction was never created due to an earlier failure; mismatched transaction scoping across async continuations.","solutions":["Ensure every EndTransaction call is paired with exactly one successful CreateTransaction/PushTransaction.","Guard EndTransaction with TransactionStack.TransactionInProgress before calling it.","Use a scope/using pattern so begin/end are paired automatically.","Do not call EndTransaction in a catch/finally block when transaction creation itself failed."],"exampleFix":"// before\nfinally { stack.EndTransaction(transaction); }\n\n// after\nfinally\n{\n    if (stack.TransactionInProgress)\n        stack.EndTransaction(transaction);\n}","handlingStrategy":"validation","validationCode":"if (!transactionStack.TransactionInProgress)\n    return; // nothing to end\ntransactionStack.EndTransaction(transaction);","typeGuard":"bool HasOpenTransaction(TransactionStack stack) => stack.TransactionInProgress;","tryCatchPattern":"try\n{\n    transactionStack.EndTransaction(transaction);\n}\ncatch (TransactionException ex) when (ex.Message.Contains(\"not transaction in progress\"))\n{\n    // transaction already ended; ignore or log\n}","preventionTips":["Pair every CreateTransaction with exactly one EndTransaction.","Avoid EndTransaction in finally blocks when transaction creation failed.","Track transaction scopes with a using helper."],"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"}