Skip to content

Commit

Permalink
Print a friendlier error message when credentials don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mconigliaro committed Feb 4, 2025
1 parent 8dc99db commit 4a033b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
- [aws] Add two minute expiration buffer to TTLs to prevent long-running
commands from failing by starting the renewal process early.
- [aws] Display AWS user code during device authorization.
- [aws] Set `AWS_DEFAULT_REGION` to `us-east-1` by default
- [aws] Set `AWS_DEFAULT_REGION` to `us-east-1` by default.
- [aws] Print a friendlier error message when credentials don't exist.

## 1.1.0 - 2022-10-18

Expand Down
6 changes: 5 additions & 1 deletion authum/plugins/aws/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def credentials(
self, name: str
) -> Union["AWSSSORoleCredentials", "AWSSAMLRoleCredentials"]:
"""Return credentials by name"""
args = self["credentials"][name]
try:
args = self["credentials"][name]
except KeyError:
authum.util.rich_stderr.print(f"No credentials named '{name}'")
exit(1)
if "start_url" in args:
return AWSSSORoleCredentials(**args)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aws_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_aws_data(random_string, aws_role_credentials):
ad.mv_credentials(random_string, new_name)

ad.rm_credentials(new_name)
with pytest.raises(KeyError):
with pytest.raises(SystemExit):
ad.credentials(new_name)


Expand Down

0 comments on commit 4a033b9

Please sign in to comment.