google/python-fire · error · InvalidEnumValue

Invalid enum value: {0} for enum type: Architecture. Valid v

Error message

Invalid enum value: {0} for enum type: Architecture. Valid values: [{1}].

What it means

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.

Source

Thrown at fire/console/platforms.py:260

    Args:
      architecture_id: str, The architecture id to parse
      error_on_unknown: bool, True to raise an exception if the id is unknown,
        False to just return None.

    Raises:
      InvalidEnumValue: If the given value cannot be parsed.

    Returns:
      ArchitectureTuple, One of the Architecture constants or None if the input
      is None.
    """
    if not architecture_id:
      return None
    for arch in Architecture._ALL:
      if arch.id == architecture_id:
        return arch
    if error_on_unknown:
      raise InvalidEnumValue(architecture_id, 'Architecture',
                             [value.id for value in Architecture._ALL])
    return None

  @staticmethod
  def Current():
    """Determines the current system architecture.

    Returns:
      ArchitectureTuple, One of the Architecture constants or None if it cannot
      be determined.
    """
    return Architecture._MACHINE_TO_ARCHITECTURE.get(platform.machine().lower())


class Platform(object):
  """Holds an operating system and architecture."""

  def __init__(self, operating_system, architecture):

View on GitHub (pinned to 716bbc23d7)

Solutions

  1. Use one of the exact ids listed in the error message (e.g. 'X86_64').
  2. Normalize platform.machine() output to the library's canonical id before calling.
  3. Prefer Architecture.Current() over manual id lookup.
  4. Pass error_on_unknown=False if unknown architectures should yield None.

Example fix

// before
arch = Architecture.FromId(platform.machine(), error_on_unknown=True)  # 'x86_64'
// after
arch = Architecture.Current()
Defensive patterns

Strategy: validation

Validate before calling

valid_ids = [v.id for v in Architecture._ALL]
if architecture_id and architecture_id not in valid_ids:
    raise SystemExit(f'{architecture_id!r} not in {valid_ids}')

Type guard

def is_known_arch_id(arch_id: str) -> bool:
    return arch_id in {v.id for v in Architecture._ALL}

Try / catch

try:
    arch = Architecture.FromId(arch_id, error_on_unknown=True)
except InvalidEnumValue as e:
    print(f'Unknown architecture id {arch_id}; valid: {e}'); sys.exit(2)

Prevention

When it happens

Trigger: 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.

Common situations: Passing platform.machine() output directly; config files storing arch names in non-canonical spelling; new ARM/Apple Silicon hosts with older library versions.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28). Data as JSON: /api/errors/7bbb1d8f9b3da4d5. Report an issue: GitHub.