Nike-Inc / gimme-aws-creds

A CLI that utilizes Okta IdP via SAML to acquire temporary AWS credentials
Apache License 2.0
920 stars 262 forks source link

Using an inherited config from the DEFAULT profile crashes the app with RecursionError #227

Open jkells opened 4 years ago

jkells commented 4 years ago

Expected Behavior

Using the following configuration file

[base-profile]
okta_username = user@example.com

[prod]
inherits = base-profile
app_url = https://example.com/app_url/prod

[DEFAULT]
inherits = base-profile
app_url = https://example.com/app_url/prod

Running gimme-aws-creds should use the default profile but instead crashes.

Current Behaviour

The app crashes with the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/gimme-aws-creds", line 17, in <module>
    GimmeAWSCreds().run()
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/main.py", line 468, in run
    self._run()
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/main.py", line 789, in _run
    self.handle_action_configure()
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/main.py", line 818, in handle_action_configure
    if not self.config.action_configure:
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/main.py", line 498, in config
    config = self.generate_config()
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/main.py", line 478, in generate_config
    self._cache['conf_dict'] = config.get_config_dict()
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/config.py", line 194, in get_config_dict
    return self._handle_config(config, profile_config)
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/config.py", line 176, in _handle_config
    **self._handle_config(config, dict(config[profile_config["inherits"]])),
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/config.py", line 176, in _handle_config
    **self._handle_config(config, dict(config[profile_config["inherits"]])),
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/site-packages/gimme_aws_creds/config.py", line 176, in _handle_config
    **self._handle_config(config, dict(config[profile_config["inherits"]])),
  [Previous line repeated 981 more times]
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 1255, in __getitem__
    return self._parser.get(self._name, key)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 799, in get
    return self._interpolation.before_get(self, section, option, value,
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 395, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 408, in _interpolate_some
    rawval = parser.get(section, option, raw=True, fallback=rest)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/configparser.py", line 1157, in _unify_values
    return _ChainMap(vardict, sectiondict, self._defaults)
  File "/usr/local/Cellar/gimme-aws-creds/2.3.4/libexec/lib/python3.8/collections/__init__.py", line 887, in __init__
    self.maps = list(maps) or [{}]          # always at least one map
RecursionError: maximum recursion depth exceeded while calling a Python object

This looks like a regression as our current config file uses this format and started failing after an update.

Your Environment

OSX Mohave, running gimme-aws-creds 2.3.4 from homebrew.

brock-bouchard commented 3 years ago

I am also seeing this issue after having to upgrade to 2.4.3 due to the okta change.