NationalSecurityAgency/ghidra · error · TypeError

Cannot get schema for {annotation}

Error message

Cannot get schema for {annotation}

What it means

Raised as TypeError when _to_schema() (in the method-registration/type-mapping code) cannot map a parameter or return annotation to one of the supported wire schemas: bool/byte/char/short/int/long/str/bytes/Address/AddressRange/TraceObject (and TraceObject subclasses). Any other annotation type falls through to this error, meaning the method cannot be serialized over TraceRMI.

Source

Thrown at Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/client.py:645

        elif t is Any:
            return sch.ANY
        elif t is bool:
            return sch.BOOL
        elif t is int:
            return sch.LONG
        elif t is str:
            return sch.STRING
        elif t is bytes:
            return sch.BYTE_ARR
        elif t is Address:
            return sch.ADDRESS
        elif t is AddressRange:
            return sch.RANGE
        elif t is TraceObject:
            return sch.OBJECT
        elif isinstance(t, type) and issubclass(t, TraceObject):
            return sch.Schema(t.__name__)
        raise TypeError(f"Cannot get schema for {annotation}")

    @classmethod
    def _to_display(cls, annotation: Any) -> str:
        _, desc = find_metadata(annotation, ParamDesc)
        if desc is not None:
            return desc.display
        return ''

    @classmethod
    def _to_description(cls, annotation: Any) -> str:
        _, desc = find_metadata(annotation, ParamDesc)
        if desc is not None:
            return desc.description
        return ''

    @classmethod
    def _make_param(cls, s: inspect.Signature, p: inspect.Parameter) -> RemoteParameter:
        schema = cls._to_schema(s, p.annotation)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Use only the supported scalar/object types for registered method signatures (see the elif chain in _to_schema).
  2. For complex data, flatten to bytes/str (e.g. JSON) or pass via a TraceObject node.
  3. For arrays, use the *_ARR schema types and the matching Python list annotations.

Example fix

# before
@method
def load(self, cfg: dict) -> None: ...
# after
import json
@method
def load(self, cfg_json: str) -> None:
    cfg = json.loads(cfg_json)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {bool, bytearray, bytes, int, str, ...}  # mirror _to_schema
if annotation not in SUPPORTED:
    raise TypeError(f'Unsupported method type {annotation}')

Type guard

def is_supported_schema_type(t) -> bool:
    import ghidratrace.sch as sch
    from ghidratrace.client import Address, AddressRange, TraceObject
    return t in (bool, bytes, str, int) or t in (Address, AddressRange, TraceObject) or (isinstance(t, type) and issubclass(t, TraceObject))

Prevention

When it happens

Trigger: Annotating a registered method param/return with an unsupported type such as float, dict, list, a custom dataclass, or a typing construct like Any. The error fires at schema resolution time during method registration/negotiation.

Common situations: Adding a new method using a domain dataclass or a plain Python type not in the supported set; assuming generics are mapped automatically.

Related errors


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