{"record":{"id":"092436636d6239b8","repo":"NationalSecurityAgency/ghidra","slug":"no-transaction-092436","errorCode":null,"errorMessage":"No transaction","messagePattern":"No transaction","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":126,"sourceCode":"\n    def require_trace(self) -> Trace[Extra]:\n        if self.trace is None:\n            raise RuntimeError(\"No trace active\")\n        return self.trace\n\n    def require_no_trace(self) -> None:\n        if self.trace is not None:\n            raise RuntimeError(\"Trace already started\")\n\n    def reset_trace(self) -> None:\n        self.trace: Optional[Trace[Extra]] = None\n        util.set_convenience_variable('_ghidra_tracing', \"false\")\n        self.reset_tx()\n\n    def require_tx(self) -> Tuple[Trace[Extra], Transaction]:\n        trace = self.require_trace()\n        if self.tx is None:\n            raise RuntimeError(\"No transaction\")\n        return trace, self.tx\n\n    def require_no_tx(self) -> None:\n        if self.tx is not None:\n            raise RuntimeError(\"Transaction already started\")\n\n    def reset_tx(self) -> None:\n        self.tx: Optional[Transaction] = None\n\n\nSTATE = State()\n\nif __name__ == '__main__':\n    lldb.SBDebugger.InitializeWithErrorHandling()\n    lldb.debugger = lldb.SBDebugger.Create()\nelif lldb.debugger:\n    lldb.debugger.HandleCommand(\n        'command container add -h \"Commands for connecting to Ghidra\" ghidra')","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L108-L144","documentation":"Raised by State.require_tx in the Ghidra LLDB agent when STATE.tx is None — i.e. no transaction is currently open on the trace. Commands that mutate the trace (putmem, regs, objects, snapshots written under tx) call require_tx to obtain a (trace, tx) pair; without an open transaction, writes are disallowed. RuntimeError signals a lifecycle precondition: a transaction must be started (commands.py:525-526, start_tx) before mutating commands.","triggerScenarios":"Running a mutating trace command (e.g. putmem, putregs, object creation) outside of a started transaction — before 'ghidra_trace_tx_start' opened one. require_tx also internally calls require_trace, so a missing trace surfaces as 196 first. Reached by the many commands calling STATE.require_tx().","commonSituations":"User issued put/record commands before opening a transaction; transaction was committed/closed and user continued mutating; script that writes without tx.","solutions":["Open a transaction (ghidra_trace_tx_start) before any mutating command, and commit/close it (ghidra_trace_tx_commit) when done.","Prefer STATE.require_trace().open_tx(description) as a context manager so the tx always closes.","Catch RuntimeError and hint 'no transaction; run ghidra_trace_tx_start'.","Ensure tx is reset (reset_tx) after commit so stale state does not confuse subsequent checks."],"exampleFix":"// before\ntrace, tx = STATE.require_tx()\n// after\nif STATE.tx is None:\n    print(\"No transaction. Run: ghidra_trace_tx_start <description>\")\n    return\ntrace, tx = STATE.require_tx()","handlingStrategy":"validation","validationCode":"if STATE.tx is None:\n    print(\"No transaction. Run: ghidra_trace_tx_start <description>\")\n    return\ntrace, tx = STATE.require_tx()","typeGuard":"def tx_open() -> bool:\n    return STATE.tx is not None","tryCatchPattern":"try:\n    trace, tx = STATE.require_tx()\nexcept RuntimeError:\n    print(\"No transaction; run ghidra_trace_tx_start first\")\n    return","preventionTips":["open a transaction before mutating commands","prefer open_tx context managers to guarantee close","reset_tx after commit"],"tags":["ghidra","lldb","runtime-error","state-machine","transaction"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}