{"record":{"id":"62913a9318040f48","repo":"NationalSecurityAgency/ghidra","slug":"object-is-not-err-msg-62913a","errorCode":null,"errorMessage":"{object} is not {err_msg}","messagePattern":"(.+?) is not (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py","lineNumber":75,"sourceCode":"REGS_PATTERN = extre(FRAME_PATTERN, '\\\\.Registers')\nMEMORY_PATTERN = extre(PROCESS_PATTERN, '\\\\.Memory')\nMODULES_PATTERN = extre(PROCESS_PATTERN, '\\\\.Modules')\nPROC_EVENTS_PATTERN = extre(PROC_DEBUG_PATTERN, '\\\\.Events')\nPROC_EVENT_PATTERN = extre(PROC_EVENTS_PATTERN, '\\\\[(?P<eventnum>\\\\d*)\\\\]')\nPROC_EVENT_CONT_PATTERN = extre(PROC_EVENT_PATTERN, '.Cont')\nPROC_EVENT_EXEC_PATTERN = extre(PROC_EVENT_PATTERN, '.Exec')\nPROC_EXCEPTIONS_PATTERN = extre(PROC_DEBUG_PATTERN, '\\\\.Exceptions')\nPROC_EXCEPTION_PATTERN = extre(\n    PROC_EXCEPTIONS_PATTERN, '\\\\[(?P<excnum>\\\\d*)\\\\]')\nPROC_EXCEPTION_CONT_PATTERN = extre(PROC_EXCEPTION_PATTERN, '.Cont')\nPROC_EXCEPTION_EXEC_PATTERN = extre(PROC_EXCEPTION_PATTERN, '.Exec')\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    if id != util.selected_process():\n        util.select_process(id)\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:","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py#L57-L93","documentation":"Raised by find_availpid_by_pattern() (methods.py:75) when a TraceObject path does not match AVAILABLE_PATTERN. This guard validates that an object represents an Attachable (an available-to-attach process) before extracting the 'pid' capture group used for attach operations.","triggerScenarios":"Calling an attach-related method with an object whose path is not under the Available container (e.g. a running Process, Thread, or Breakpoint object); path schema drift; invoking attach with a manually constructed TraceObject of the wrong type.","commonSituations":"Passing a Processes[...] object instead of an Available[...] object to an attach method; stale schema after a Ghidra version upgrade; misrouted method dispatch in custom scripts.","solutions":["Pass an object whose path matches the Available container pattern (e.g. 'Available[1234]').","List available processes first and select the object from that container, not from Processes.","Verify schema.xml / schema_exdi.xml version matches the agent build."],"exampleFix":"// before\nattach_proc(processes_obj)   # path like 'Processes[0]'\n\n// after\n# obtain from the Available container:\navail_obj = trace.get_object('Available[1234]')\nattach_proc(avail_obj)","handlingStrategy":"type-guard","validationCode":"from ghidradbg.methods import AVAILABLE_PATTERN\n\ndef is_attachable_obj(obj) -> bool:\n    return AVAILABLE_PATTERN.fullmatch(obj.path) is not None\n\nif not is_attachable_obj(obj):\n    raise ValueError('expected an Attachable (Available[...]) object')","typeGuard":"def is_attachable_obj(obj) -> bool:\n    from ghidradbg.methods import AVAILABLE_PATTERN\n    return bool(getattr(obj, 'path', None)) and AVAILABLE_PATTERN.fullmatch(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'not an Attachable object: {obj}') from e\n    raise","preventionTips":["Source attach targets from the Available container, not Processes.","Validate the path pattern before calling attach helpers.","Keep schema versions in sync between agent and trace."],"tags":["type-guard","pattern-match","process","ghidra"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}