NationalSecurityAgency/ghidra · error · TypeError

{object} is not {err_msg}

Error message

{object} is not {err_msg}

What it means

Raised by find_availpid_by_pattern (methods.py:57) as a TypeError when a TraceObject's path does not match the AVAILABLE_PATTERN (`Available[<pid>]`). The function extracts a pid from the path via regex fullmatch; a non-matching path means the object is not an 'Available' node, so the agent refuses to derive a pid from it.

Source

Thrown at Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/methods.py:57

PROC_BREAKS_PATTERN = extre(PROCESS_PATTERN, '\.Breakpoints')
PROC_BREAK_PATTERN = extre(PROC_BREAKS_PATTERN, '\[(?P<breaknum>\\d*)\]')
PROC_BREAKLOC_PATTERN = extre(PROC_BREAK_PATTERN, '\[(?P<locnum>\\d*)\]')
PROC_WATCHES_PATTERN = extre(PROCESS_PATTERN, '\.Watchpoints')
PROC_WATCH_PATTERN = extre(PROC_WATCHES_PATTERN, '\[(?P<watchnum>\\d*)\]')
ENV_PATTERN = extre(PROCESS_PATTERN, '\.Environment')
THREADS_PATTERN = extre(PROCESS_PATTERN, '\.Threads')
THREAD_PATTERN = extre(THREADS_PATTERN, '\[(?P<tnum>\\d*)\]')
STACK_PATTERN = extre(THREAD_PATTERN, '\.Stack')
FRAME_PATTERN = extre(STACK_PATTERN, '\[(?P<level>\\d*)\]')
REGS_PATTERN = extre(FRAME_PATTERN, '.Registers')
MEMORY_PATTERN = extre(PROCESS_PATTERN, '\.Memory')
MODULES_PATTERN = extre(PROCESS_PATTERN, '\.Modules')


def find_availpid_by_pattern(pattern: re.Pattern, object: TraceObject, err_msg: str) -> int:
    mat = pattern.fullmatch(object.path)
    if mat is None:
        raise TypeError(f"{object} is not {err_msg}")
    pid = int(mat['pid'])
    return pid


def find_availpid_by_obj(object: TraceObject) -> int:
    return find_availpid_by_pattern(AVAILABLE_PATTERN, object, "an Available")


def find_proc_by_num(procnum: int) -> lldb.SBProcess:
    return util.get_process()


def find_proc_by_pattern(object: TraceObject, pattern: re.Pattern,
                         err_msg: str) -> lldb.SBProcess:
    mat = pattern.fullmatch(object.path)
    if mat is None:
        raise TypeError(f"{object} is not {err_msg}")
    procnum = int(mat['procnum'])

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the object path is exactly `Available[<pid>]` before invoking the method.
  2. Restart/refresh the trace so the schema and available list are consistent with the current target.
  3. Ensure the agent and Ghidra versions match to avoid pattern/schema drift.
Defensive patterns

Strategy: type-guard

Validate before calling

import re
AVAILABLE_PATTERN = re.compile(r'Available\[(?P<pid>\d*)\]')
def is_available_obj(path: str) -> bool:
    return AVAILABLE_PATTERN.fullmatch(path) is not None

Type guard

def is_available_obj(path: str) -> bool:
    import re
    return re.fullmatch(r'Available\[\d*\]', path) is not None

Try / catch

try:
    pid = find_availpid_by_obj(obj)
except TypeError:
    # obj is not an Available node; re-route to the correct method/handler
    ...

Prevention

When it happens

Trigger: Ghidra's TraceRmi invokes an Available-scoped method (e.g. attach by available process) on an object whose path is a Process, Threads, Memory, or malformed node instead of `Available[<pid>]`. Caused by schema/path mismatch between Ghidra and the agent, stale traces, or a method routed to the wrong object type.

Common situations: Version skew between the agent and Ghidra's object schema; using a trace opened against a different target; or custom method invocations that pass an arbitrary object path. The error is an internal API contract violation more than a user typo.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/3345ba96f4550811. Report an issue: GitHub.