{"record":{"id":"bd8a96a46ecc51dc","repo":"google/python-fire","slug":"invalid-enum-value-0-for-enum-type-operating-s","errorCode":null,"errorMessage":"Invalid enum value: {0} for enum type: Operating System. Valid values: [{1}].","messagePattern":"Invalid enum value: (.+?) for enum type: Operating System\\. Valid values: \\[(.+?)\\]\\.","errorType":"validation","errorClass":"InvalidEnumValue","httpStatus":null,"severity":"error","filePath":"fire/console/platforms.py","lineNumber":136,"sourceCode":"    Args:\n      os_id: str, The operating system 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      OperatingSystemTuple, One of the OperatingSystem constants or None if the\n      input is None.\n    \"\"\"\n    if not os_id:\n      return None\n    for operating_system in OperatingSystem._ALL:\n      if operating_system.id == os_id:\n        return operating_system\n    if error_on_unknown:\n      raise InvalidEnumValue(os_id, 'Operating System',\n                             [value.id for value in OperatingSystem._ALL])\n    return None\n\n  @staticmethod\n  def Current():\n    \"\"\"Determines the current operating system.\n\n    Returns:\n      OperatingSystemTuple, One of the OperatingSystem constants or None if it\n      cannot be determined.\n    \"\"\"\n    if os.name == 'nt':\n      return OperatingSystem.WINDOWS\n    elif 'linux' in sys.platform:\n      return OperatingSystem.LINUX\n    elif 'darwin' in sys.platform:\n      return OperatingSystem.MACOSX\n    elif 'cygwin' in sys.platform:","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/console/platforms.py#L118-L154","documentation":"OperatingSystem.FromId maps a short OS id (e.g. 'LINUX', 'WINDOWS') to an OperatingSystem enum member. If no member's id matches the supplied os_id and error_on_unknown is true, it raises InvalidEnumValue listing the valid ids. If os_id is falsy it returns None instead of raising.","triggerScenarios":"Calling OperatingSystem.FromId('mac', error_on_unknown=True) or FromId(platform.system()) with a raw string that is not one of the library's recognized ids; usually caused by feeding unnormalized platform strings into the enum lookup.","commonSituations":"Deriving the OS from platform.system() ('Darwin' vs expected ids), user-supplied config values, or a library version where the id set changed.","solutions":["Print the valid ids (the error lists them) and use one of those exact strings.","Map your platform string to a known id before calling (e.g. 'Darwin' -> 'MACOSX' depending on the library's id set).","Use OperatingSystem.Current() instead of manual id construction.","Pass error_on_unknown=False if a None result is acceptable."],"exampleFix":"// before\nos_enum = OperatingSystem.FromId(platform.system(), error_on_unknown=True)  # 'Darwin'\n// after\nos_enum = OperatingSystem.Current()","handlingStrategy":"validation","validationCode":"valid_ids = [v.id for v in OperatingSystem._ALL]\nif os_id and os_id not in valid_ids:\n    raise SystemExit(f'{os_id!r} not in {valid_ids}')","typeGuard":"def is_known_os_id(os_id: str) -> bool:\n    return os_id in {v.id for v in OperatingSystem._ALL}","tryCatchPattern":"try:\n    os_enum = OperatingSystem.FromId(os_id, error_on_unknown=True)\nexcept InvalidEnumValue as e:\n    print(f'Unknown OS id {os_id}; valid: {e}'); sys.exit(2)","preventionTips":["Use OperatingSystem.Current() instead of constructing ids manually.","Normalize raw platform.system()/uname output to canonical ids first.","Validate user/config-supplied ids against the enum before lookup."],"tags":["python","enum","validation","platform"],"backgroundTag":"invalid-enum-value","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}