Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSecret (et. al.) now raise SystemExit sometimes? #276

Closed
glyph opened this issue Feb 27, 2020 · 1 comment · Fixed by #280
Closed

getSecret (et. al.) now raise SystemExit sometimes? #276

glyph opened this issue Feb 27, 2020 · 1 comment · Fixed by #280
Milestone

Comments

@glyph
Copy link

glyph commented Feb 27, 2020

The addition of @clean_fail in https://github.com/fugue/credstash/pull/263/files has changed the error-handling behavior of getSecret et. al. to raise SystemExit sometimes. This is pretty aggressive behavior for API clients, since it causes a sudden and inexplicable exit where there used to be a normally-handleable (if somewhat obscure) error.

@sconnel42
Copy link

Is there any update on this? I have an API that is trying to do a get_or_create action by first calling getSecret, and this is causing a hard exit. You can see that behavior with this script:

# sample_get_or_create.py
import credstash


def get_or_create_secret(key):
    secret = None
    try:
        secret = credstash.getSecret(key, region="us-east-1")
        print(f"Found a secret for {key}!")
    except credstash.ItemNotFound:
        print(f"No key of '{key}' found, creating a new value")
        secret = "bazbaz"
    return secret


if __name__ == "__main__":
    key = "foobar"
    secret = get_or_create_secret(key)
    print(f"{key}: {secret}")

Running that on the latest version of credstash (1.16.2) gives:

$ poetry run python sample_get_or_create.py                 
Item {'name': 'foobar'} couldn't be found.

Where this works as expected on the previous version of credstash (1.16.1):

$ poetry run python sample_get_or_create.py
No key of 'foobar' found, creating a new value
foobar: bazbaz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants