{"record":{"id":"eefe5c0673b4cb17","repo":"NationalSecurityAgency/ghidra","slug":"ghidra-trace-connect-missing-required-argument-eefe5c","errorCode":null,"errorMessage":"'ghidra_trace_connect': missing required argument 'address'","messagePattern":"'ghidra_trace_connect': missing required argument 'address'","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py","lineNumber":168,"sourceCode":"        if self.tx != 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\n\ndef ghidra_trace_connect(address: Optional[str] = None) -> None:\n    \"\"\"Connect Python to Ghidra for tracing.\n\n    Address must be of the form 'host:port'\n    \"\"\"\n\n    STATE.require_no_client()\n    if address is None:\n        raise RuntimeError(\n            \"'ghidra_trace_connect': missing required argument 'address'\")\n\n    parts = address.split(':')\n    if len(parts) != 2:\n        raise RuntimeError(\"address must be in the form 'host:port'\")\n    host, port = parts\n    try:\n        c = socket.socket()\n        c.connect((host, int(port)))\n        # TODO: Can we get version info from the DLL?\n        STATE.client = Client(c, \"x64dbg\", methods.REGISTRY)\n        print(f\"Connected to {STATE.client.description} at {address}\")\n    except ValueError:\n        raise RuntimeError(\"port must be numeric\")\n\n\ndef ghidra_trace_listen(address: str = '127.0.0.1:0') -> None:\n    \"\"\"Listen for Ghidra to connect for tracing.","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py#L150-L186","documentation":"Raised by ghidra_trace_connect (commands.py:166-169) when the address argument is None. The function signature is address: Optional[str] = None, so calling it with no positional/keyword argument satisfies the type but fails the precondition that an address be supplied. require_no_client() runs first, so this only fires when there is no existing client.","triggerScenarios":"Invoking ghidra_trace_connect() with no argument at all, or explicitly ghidra_trace_connect(address=None). Occurs when the command is dispatched from a UI/script that forwards no parameter.","commonSituations":"A menu item or wrapper script wired to the command without binding an address field; mistaking the Optional default for a 'connect to default' behavior; a bridge that passes None when the user left the field blank.","solutions":["Pass a host:port string, e.g. ghidra_trace_connect('127.0.0.1:12345').","If wrapping the command, require a non-empty address from the user before calling.","Use ghidra_trace_listen() instead if you want Ghidra to connect to the agent rather than the agent connecting out."],"exampleFix":"// before\nghidra_trace_connect()\n\n// after\nghidra_trace_connect('127.0.0.1:12345')","handlingStrategy":"validation","validationCode":"def connect(address=None):\n    if not address:\n        raise ValueError('address is required (host:port)')\n    ghidra_trace_connect(address)","typeGuard":"def has_address(address) -> bool:\n    return isinstance(address, str) and bool(address.strip())","tryCatchPattern":"try:\n    ghidra_trace_connect(address)\nexcept RuntimeError as e:\n    if 'missing required argument' in str(e):\n        address = prompt_user('host:port')\n        ghidra_trace_connect(address)\n    else:\n        raise","preventionTips":["Bind the command to a required, non-empty address field in your UI.","Treat an empty address as a hard error before dispatching the command.","Prefer ghidra_trace_listen if the direction of connection is reversed."],"tags":["connect","argument-validation","trace-agent","python"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}