fix: Handle KeyError in platform info retrieval with clear message

This commit is contained in:
Paul Gauthier (aider) 2025-03-21 11:23:50 -07:00
parent 821662abcb
commit d6906fb100

View file

@ -1033,9 +1033,9 @@ class Coder:
platform_text = ""
try:
platform_text = f"- Platform: {platform.platform()}\n"
except Exception:
except (Exception, KeyError):
# Skip platform info if it can't be retrieved
pass
platform_text = "- Platform information unavailable\n"
shell_var = "COMSPEC" if os.name == "nt" else "SHELL"
shell_val = os.getenv(shell_var)