{"record":{"id":"6936c5f841348fce","repo":"NationalSecurityAgency/ghidra","slug":"object-is-not-err-msg-6936c5","errorCode":null,"errorMessage":"{object} is not {err_msg}","messagePattern":"(.+?) is not (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py","lineNumber":116,"sourceCode":"class Thread(TraceObject):\n    pass\n\n\nclass ThreadContainer(TraceObject):\n    pass\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:\n        raise TypeError(f\"{object} is not {err_msg}\")\n    procnum = int(mat['procnum'])\n    return find_proc_by_num(procnum)\n\n\ndef find_proc_by_obj(object: TraceObject) -> int:\n    return find_proc_by_pattern(object, PROCESS_PATTERN, \"an Process\")\n\n\ndef find_proc_by_env_obj(object: TraceObject) -> int:\n    return find_proc_by_pattern(object, ENV_PATTERN, \"an Environment\")\n\n\ndef find_proc_by_threads_obj(object: TraceObject) -> int:\n    return find_proc_by_pattern(object, THREADS_PATTERN, \"a ThreadContainer\")\n\n\ndef find_proc_by_mem_obj(object: TraceObject) -> int:\n    return find_proc_by_pattern(object, MEMORY_PATTERN, \"a Memory\")","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py#L98-L134","documentation":"Thrown as a TypeError by find_proc_by_pattern in the drgn agent when a TraceObject's path does not match the PROCESS_PATTERN regex. This function extracts a process number from the object's canonical path string; a non-matching path means the object is not a valid process reference.","triggerScenarios":"Passing a TraceObject whose path does not conform to the process path schema (e.g. a thread path like 'Processes[1].Threads[2]' when a process path like 'Processes[1]' is expected). The regex fullmatch fails and TypeError is raised.","commonSituations":"Calling a method that expects a process object with a thread, frame, or module object instead; path string was manually constructed incorrectly; the Ghidra UI passed the wrong object type to a drgn method.","solutions":["Pass a TraceObject whose path matches the process pattern, e.g. 'Processes[1]'.","Verify the object type before calling — use find_proc_by_obj which delegates to this function.","Check that the path string has the exact format 'Processes[<procnum>]'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import re\n# PROCESS_PATTERN must match the one defined in methods.py\nPROCESS_PATTERN_TEST = re.compile(r'Processes\\[(?P<procnum>\\d+)\\]')\n\ndef is_process_path(path: str) -> bool:\n    return PROCESS_PATTERN_TEST.fullmatch(path) is not None","typeGuard":"def is_process_object(obj: TraceObject) -> bool:\n    return PROCESS_PATTERN_TEST.fullmatch(obj.path) is not None","tryCatchPattern":"try:\n    find_proc_by_obj(obj)\nexcept TypeError as e:\n    print(f'Object path does not match process pattern: {obj.path}')\n    raise","preventionTips":["Verify the TraceObject path matches 'Processes[<n>]' before calling process methods.","Use the correct find_*_by_obj function for each object type.","Check obj.path format in the Ghidra UI before passing to the API."],"tags":["drgn","type-mismatch","trace-objects","pattern-matching"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}