{"record":{"id":"8174566a0ee229e1","repo":"NationalSecurityAgency/ghidra","slug":"object-is-not-err-msg-817456","errorCode":null,"errorMessage":"{object} is not {err_msg}","messagePattern":"(.+?) is not (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/methods.py","lineNumber":69,"sourceCode":"PROC_SBREAKBPT_PATTERN = extre(PROC_SBREAKS_PATTERN, '\\\\[(?P<breaknum>\\\\d*)\\\\]')\nPROC_HBREAKBPT_PATTERN = extre(PROC_HBREAKS_PATTERN, '\\\\[(?P<breaknum>\\\\d*)\\\\]')\nPROC_MBREAKBPT_PATTERN = extre(PROC_MBREAKS_PATTERN, '\\\\[(?P<breaknum>\\\\d*)\\\\]')\nENV_PATTERN = extre(PROCESS_PATTERN, '\\\\.Environment')\nTHREADS_PATTERN = extre(PROCESS_PATTERN, '\\\\.Threads')\nTHREAD_PATTERN = extre(THREADS_PATTERN, '\\\\[(?P<tnum>\\\\d*)\\\\]')\nSTACK_PATTERN = extre(THREAD_PATTERN, '\\\\.Stack.Frames')\n#FRAME_PATTERN = extre(STACK_PATTERN, '\\\\[(?P<level>\\\\d*)\\\\]')\nREGS_PATTERN0 = extre(THREAD_PATTERN, '\\\\.Registers')\n#REGS_PATTERN = extre(FRAME_PATTERN, '\\\\.Registers')\nMEMORY_PATTERN = extre(PROCESS_PATTERN, '\\\\.Memory')\nMODULES_PATTERN = extre(PROCESS_PATTERN, '\\\\.Modules')\n\n\ndef find_availpid_by_pattern(pattern: re.Pattern, object: TraceObject,\n                             err_msg: str) -> int:\n    mat = pattern.fullmatch(object.path)\n    if mat is None:\n        raise TypeError(f\"{object} is not {err_msg}\")\n    pid = int(mat['pid'])\n    return pid\n\n\ndef find_availpid_by_obj(object: TraceObject) -> int:\n    return find_availpid_by_pattern(AVAILABLE_PATTERN, object, \"an Attachable\")\n\n\ndef find_proc_by_num(id: int) -> int:\n    return util.selected_process()\n\n\ndef find_proc_by_pattern(object: TraceObject, pattern: re.Pattern,\n                         err_msg: str) -> int:\n    mat = pattern.fullmatch(object.path)\n    if mat is None:\n        raise TypeError(f\"{object} is not {err_msg}\")\n    procnum = int(mat['procnum'])","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/methods.py#L51-L87","documentation":"Raised as a TypeError by find_availpid_by_pattern (methods.py:67-69) when the TraceObject's path does not fullmatch AVAILABLE_PATTERN (Sessions[snum].Available[pid]). err_msg is 'an Attachable'. The agent routes trace-RMI method calls by matching object paths against compiled regexes; a mismatch means the caller supplied an object of the wrong kind.","triggerScenarios":"A trace-RMI method that expects an Attachable object is invoked with a TraceObject whose path is a Process, Thread, Memory, or any other node. pattern.fullmatch(object.path) returns None.","commonSituations":"The UI/method caller activates the wrong object type (e.g. a Processes node instead of an Available node) and a method bound to attach is fired; schema/path drift where the object tree shape changed but the method binding did not.","solutions":["Pass a TraceObject whose path matches the Available pattern (Sessions[s].Available[pid]).","Verify object.path matches AVAILABLE_PATTERN before invoking the attach-related method.","Ensure the trace schema and object tree are populated so the Available nodes exist."],"exampleFix":"// before\nfind_availpid_by_obj(process_object)  # path is Processes[0]\n\n// after\nfind_availpid_by_obj(available_object)  # path is Sessions[0].Available[1234]","handlingStrategy":"type-guard","validationCode":"def require_attachable(obj):\n    if AVAILABLE_PATTERN.fullmatch(obj.path) is None:\n        raise ValueError(f'{obj.path} is not an Attachable path')\n    return find_availpid_by_obj(obj)","typeGuard":"def is_attachable(obj) -> bool:\n    return AVAILABLE_PATTERN.fullmatch(getattr(obj, 'path', '')) is not None","tryCatchPattern":"try:\n    pid = find_availpid_by_obj(obj)\nexcept TypeError as e:\n    if 'is not' in str(e):\n        raise ValueError(f'Activate an Available node, not {obj.path}') from e\n    raise","preventionTips":["Confirm the active object's path matches the Available pattern before attach calls.","Build object paths from the schema constants rather than hand-crafted strings.","Handle TypeError from the finders and surface a clear 'wrong object type' message."],"tags":["pattern-matching","object-routing","trace-rmi","python"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}