Skip to content

Commit b9aeede

Browse files
committed
fix(Accounts): log access warning, do not raise in container .keys
NOTE: This will make sure that Ape API issues do not raise e.g. `ape accounts list --all` and tracing features
1 parent 6e8d7e6 commit b9aeede

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ape_aws/accounts.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Any, Iterator, Optional
33

44
from ape.api.accounts import AccountAPI, AccountContainerAPI, TransactionAPI
5+
from ape.logging import logger
56
from ape.types import AddressType, MessageSignature, SignableMessage, TransactionSignature
67
from eth_account._utils.legacy_transactions import serializable_unsigned_transaction_from_dict
78
from eth_account.messages import _hash_eip191_message, encode_defunct
@@ -11,6 +12,7 @@
1112
from ape_aws.exceptions import ApeAwsException
1213

1314
from .client import AwsClient
15+
from .exceptions import AwsAccessError
1416
from .kms.client import KmsKey
1517
from .utils import _convert_der_to_rsv
1618

@@ -20,6 +22,16 @@ def __init__(self, *args, **kwargs):
2022
super(AwsClient, self).__init__() # NOTE: Use config/envvar default
2123
super(AccountContainerAPI, self).__init__(*args, **kwargs)
2224

25+
@property
26+
def keys(self) -> dict[str, KmsKey]: # type: ignore[syntax]
27+
try:
28+
return super(AwsClient, self).keys
29+
30+
except AwsAccessError as e:
31+
# NOTE: Do not raise here, instead just log warning (prevent issues w/ Ape API)
32+
logger.warning(str(e))
33+
return {}
34+
2335
@property
2436
def aliases(self) -> Iterator[str]:
2537
yield from iter(self.keys)

0 commit comments

Comments
 (0)