{"record":{"id":"7bbb1d8f9b3da4d5","repo":"google/python-fire","slug":"invalid-enum-value-0-for-enum-type-architectur","errorCode":null,"errorMessage":"Invalid enum value: {0} for enum type: Architecture. Valid values: [{1}].","messagePattern":"Invalid enum value: (.+?) for enum type: Architecture\\. Valid values: \\[(.+?)\\]\\.","errorType":"validation","errorClass":"InvalidEnumValue","httpStatus":null,"severity":"error","filePath":"fire/console/platforms.py","lineNumber":260,"sourceCode":"    Args:\n      architecture_id: str, The architecture id to parse\n      error_on_unknown: bool, True to raise an exception if the id is unknown,\n        False to just return None.\n\n    Raises:\n      InvalidEnumValue: If the given value cannot be parsed.\n\n    Returns:\n      ArchitectureTuple, One of the Architecture constants or None if the input\n      is None.\n    \"\"\"\n    if not architecture_id:\n      return None\n    for arch in Architecture._ALL:\n      if arch.id == architecture_id:\n        return arch\n    if error_on_unknown:\n      raise InvalidEnumValue(architecture_id, 'Architecture',\n                             [value.id for value in Architecture._ALL])\n    return None\n\n  @staticmethod\n  def Current():\n    \"\"\"Determines the current system architecture.\n\n    Returns:\n      ArchitectureTuple, One of the Architecture constants or None if it cannot\n      be determined.\n    \"\"\"\n    return Architecture._MACHINE_TO_ARCHITECTURE.get(platform.machine().lower())\n\n\nclass Platform(object):\n  \"\"\"Holds an operating system and architecture.\"\"\"\n\n  def __init__(self, operating_system, architecture):","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/console/platforms.py#L242-L278","documentation":"Architecture.FromId maps an architecture id (e.g. 'X86_64') to an Architecture enum member. On an unmatched architecture_id with error_on_unknown=True it raises InvalidEnumValue enumerating the valid ids; an empty/None id returns None without raising.","triggerScenarios":"Calling Architecture.FromId('x86-64', error_on_unknown=True) or FromId(platform.machine()) with raw machine strings ('x86_64', 'arm64', 'AMD64') that don't match the library's canonical ids; also when running on an architecture the installed version doesn't enumerate.","commonSituations":"Passing platform.machine() output directly; config files storing arch names in non-canonical spelling; new ARM/Apple Silicon hosts with older library versions.","solutions":["Use one of the exact ids listed in the error message (e.g. 'X86_64').","Normalize platform.machine() output to the library's canonical id before calling.","Prefer Architecture.Current() over manual id lookup.","Pass error_on_unknown=False if unknown architectures should yield None."],"exampleFix":"// before\narch = Architecture.FromId(platform.machine(), error_on_unknown=True)  # 'x86_64'\n// after\narch = Architecture.Current()","handlingStrategy":"validation","validationCode":"valid_ids = [v.id for v in Architecture._ALL]\nif architecture_id and architecture_id not in valid_ids:\n    raise SystemExit(f'{architecture_id!r} not in {valid_ids}')","typeGuard":"def is_known_arch_id(arch_id: str) -> bool:\n    return arch_id in {v.id for v in Architecture._ALL}","tryCatchPattern":"try:\n    arch = Architecture.FromId(arch_id, error_on_unknown=True)\nexcept InvalidEnumValue as e:\n    print(f'Unknown architecture id {arch_id}; valid: {e}'); sys.exit(2)","preventionTips":["Use Architecture.Current() rather than platform.machine() directly.","Normalize machine strings (x86_64/AMD64/arm64) to canonical ids.","Validate config-stored arch ids at startup."],"tags":["python","enum","validation","architecture"],"backgroundTag":"invalid-enum-value","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}