{"record":{"id":"d6c51d5fc22e85ec","repo":"NationalSecurityAgency/ghidra","slug":"invalid-byte-order-d6c51d","errorCode":null,"errorMessage":"Invalid byte_order: {}","messagePattern":"Invalid byte_order: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/arch.py","lineNumber":187,"sourceCode":"            f\"Address {address} is not in process {proc}\")\n\n\nDEFAULT_MEMORY_MAPPER = DefaultMemoryMapper('ram')\n\nmemory_mappers: Dict[str, DefaultMemoryMapper] = {}\n\n\ndef compute_memory_mapper(lang: str) -> DefaultMemoryMapper:\n    if not lang in memory_mappers:\n        return DEFAULT_MEMORY_MAPPER\n    return memory_mappers[lang]\n\n\nclass DefaultRegisterMapper(object):\n\n    def __init__(self, byte_order: str) -> None:\n        if not byte_order in ['big', 'little']:\n            raise ValueError(\"Invalid byte_order: {}\".format(byte_order))\n        self.byte_order = byte_order\n\n    def map_name(self, proc: int, name: str) -> str:\n        return name\n\n    def map_value(self, proc: int, name: str, value: bytes):\n        return RegVal(self.map_name(proc, name), value)\n\n    def map_name_back(self, proc: int, name: str):\n        return name\n\n    def map_value_back(self, proc: int, name: str, value: bytes):\n        return RegVal(self.map_name_back(proc, name), value)\n\n\nDEFAULT_BE_REGISTER_MAPPER = DefaultRegisterMapper('big')\nDEFAULT_LE_REGISTER_MAPPER = DefaultRegisterMapper('little')\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/arch.py#L169-L205","documentation":"Raised as ValueError by DefaultRegisterMapper.__init__() when byte_order is neither 'big' nor 'little'. It is a construction-time guard ensuring register byte serialization is well-defined.","triggerScenarios":"Instantiating DefaultRegisterMapper (directly or via compute_register_mapper) with a byte_order string outside {'big','little'}.","commonSituations":"Passing an arch endianness token like 'BE'/'LE'/'big-endian' instead of the exact 'big'/'little' strings; misconfigured language id that yields an unexpected endianness.","solutions":["Normalize the byte_order argument to exactly 'big' or 'little' before constructing the mapper.","Fix the language-id detection (compute_register_mapper) so it maps to a valid endianness.","Guard the value with an assert or precondition before construction."],"exampleFix":"// before\nmapper = DefaultRegisterMapper('BE')  # raises\n// after\nbo = 'big' if endian in ('big','BE','big-endian') else 'little'\nmapper = DefaultRegisterMapper(bo)","handlingStrategy":"validation","validationCode":"if byte_order not in ('big', 'little'):\n    raise ValueError(f'byte_order must be big/little, got {byte_order!r}')\nmapper = arch.DefaultRegisterMapper(byte_order)","typeGuard":"def is_valid_byte_order(bo) -> bool:\n    return bo in ('big', 'little')","tryCatchPattern":"try:\n    mapper = arch.DefaultRegisterMapper(byte_order)\nexcept ValueError as e:\n    bo = 'big' if str(byte_order).upper().startswith('B') else 'little'\n    mapper = arch.DefaultRegisterMapper(bo)","preventionTips":["Normalize endianness tokens to exactly 'big'/'little' before constructing the mapper.","Fix language-id detection so compute_register_mapper() yields a valid endianness.","Assert the value at the boundary (config/UI) rather than deep in the mapper."],"tags":["drgn","register-mapper","byte-order","valueerror"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}