victorskl / yawsso

Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials
MIT License
304 stars 27 forks source link

Time formatting error #41

Closed smashedtoatoms closed 3 years ago

smashedtoatoms commented 3 years ago

I just loaded yawsso on a macbook pro with an M1 running python 3.9.1, and it appears to be failing due to datetime formatting issue. I ran a few versions of the command to hopefully help troubleshoot.

➜  ~ file $(which python)
/opt/local/bin/python: Mach-O 64-bit executable arm64
➜  ~ yawsso --default
Traceback (most recent call last):
  File "/Users/me/.local/bin//yawsso", line 8, in <module>
    sys.exit(main())
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 509, in main
    credentials = update_profile("default", config)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 345, in update_profile
    credentials = fetch_credentials(profile_name, profile)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 224, in fetch_credentials
    cached_login = check_sso_cached_login_expires(profile_name, profile)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 215, in check_sso_cached_login_expires
    expires_utc = parse_sso_cached_login_expiry(cached_login)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 180, in parse_sso_cached_login_expiry
    expires_utc = datetime.strptime((cached_login["expiresAt"]), datetime_format_in_sso_cached_login)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2020-12-28T23:44:36Z' does not match format '%Y-%m-%dT%H:%M:%SUTC'
➜  ~ yawsso
Traceback (most recent call last):
  File "/Users/me/.local/bin//yawsso", line 8, in <module>
    sys.exit(main())
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 540, in main
    credentials = update_profile(profile_name, config)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 345, in update_profile
    credentials = fetch_credentials(profile_name, profile)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 224, in fetch_credentials
    cached_login = check_sso_cached_login_expires(profile_name, profile)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 215, in check_sso_cached_login_expires
    expires_utc = parse_sso_cached_login_expiry(cached_login)
  File "/Users/me/.local/pipx/venvs/yawsso/lib/python3.9/site-packages/yawsso/cli.py", line 180, in parse_sso_cached_login_expiry
    expires_utc = datetime.strptime((cached_login["expiresAt"]), datetime_format_in_sso_cached_login)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2020-12-28T23:44:36Z' does not match format '%Y-%m-%dT%H:%M:%SUTC'

I am not sure if it's python 3.9.1's _strptime behavior has changed in general, on arm, or what. Let me know if I can help troubleshoot it any more or if you need more detail.

victorskl commented 3 years ago

Thanks for reporting. It is related to UTC format changes in aws cli as reported in #42 I will patch the fix provided there in a tick. Cheers!

smashedtoatoms commented 3 years ago

closing since #42 will resolve this one. Thanks.

victorskl commented 3 years ago

Fixed #41 #42. Please upgrade to pip install -U yawsso==0.6.1