{"record":{"id":"d0a79e403769707c","repo":"NationalSecurityAgency/ghidra","slug":"invalid-byte-order-d0a79e","errorCode":null,"errorMessage":"Invalid byte_order: {}","messagePattern":"Invalid byte_order: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/arch.py","lineNumber":173,"sourceCode":"        raise ValueError(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):\n        return name\n\n    def map_value(self, proc: int, name: str, value: int):\n        try:\n            # TODO: this seems half-baked\n            av = value.to_bytes(8, \"big\")\n        except Exception:\n            raise ValueError(\"Cannot convert {}'s value: '{}', type: '{}'\"\n                             .format(name, value, type(value)))\n        return RegVal(self.map_name(proc, name), av)\n\n    def map_name_back(self, proc: int, name: str) -> str:\n        return name\n\n    def map_value_back(self, proc: int, name: str, value: bytes):","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/arch.py#L155-L191","documentation":"Raised by DefaultRegisterMapper.__init__ when byte_order is not one of 'big' or 'little'. The register mapper needs a known endianness to correctly serialize register values; any other string (or typo) is rejected at construction time.","triggerScenarios":"DefaultRegisterMapper is instantiated with a byte_order argument that is not in ['big', 'little']. This can happen in compute_register_mapper or in a custom subclass that calls super().__init__ with an invalid value.","commonSituations":"A custom register mapper subclass passes an unsupported endianness string. A language-detection function returns an unexpected endianness tag. A typo such as 'Big' or 'BIG' instead of 'big'.","solutions":["Ensure byte_order is exactly 'big' or 'little' (case-sensitive) when constructing DefaultRegisterMapper.","Normalize the endianness string to lowercase before passing it to the constructor.","Register the language in register_mappers so compute_register_mapper returns a pre-built mapper instead of constructing one with a derived value."],"exampleFix":"# before: non-standard value\nmapper = DefaultRegisterMapper('Big')  # capital B triggers ValueError\n\n# after: normalize\nbyte_order = byte_order.lower()\nassert byte_order in ('big', 'little'), f\"Invalid byte_order: {byte_order}\"\nmapper = DefaultRegisterMapper(byte_order)","handlingStrategy":"validation","validationCode":"byte_order = byte_order.lower()\nif byte_order not in ('big', 'little'):\n    raise ValueError(f\"Invalid byte_order: {byte_order}; must be 'big' or 'little'\")","typeGuard":"def is_valid_byte_order(val: str) -> bool:\n    return val in ('big', 'little')","tryCatchPattern":null,"preventionTips":["Normalize byte_order to lowercase and validate against ('big', 'little') before construction.","Use pre-built mappers from register_mappers dict when available for the target language.","Avoid deriving byte_order strings from untrusted or user-supplied input."],"tags":["x64dbg","debugger-agent","register-mapper","valueerror","endianness"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}