From 0364195ca43bb7a9df288dcfc9c464b9247b0721 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 4 Oct 2023 11:22:35 +0530 Subject: [PATCH] fix: raise when the dependency set size changes while fetching the agent --- aea/cli/fetch.py | 18 +++++++++++++++--- docs/api/crypto/helpers.md | 14 -------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/aea/cli/fetch.py b/aea/cli/fetch.py index d01a338a6a..3e881a3a09 100644 --- a/aea/cli/fetch.py +++ b/aea/cli/fetch.py @@ -268,9 +268,21 @@ def _fetch_agent_deps(ctx: Context) -> None: """ for item_type in (PROTOCOL, CONTRACT, CONNECTION, SKILL): item_type_plural = "{}s".format(item_type) - required_items = getattr(ctx.agent_config, item_type_plural) - for item_id in required_items: - add_item(ctx, item_type, item_id) + required_items = cast(set, getattr(ctx.agent_config, item_type_plural)) + required_items_check = required_items.copy() + try: + for item_id in required_items: + add_item(ctx, item_type, item_id) + except RuntimeError as e: + missing_deps = required_items_check.symmetric_difference(required_items) + error = "\n- ".join( + [ + "Size of the dependency set changed during the iteration; " + "Following dependencies are missing from the agent configuration: ", + *map(lambda x: str(x.without_hash()), missing_deps), + ] + ) + raise click.ClickException(error) from e def fetch_mixed( diff --git a/docs/api/crypto/helpers.md b/docs/api/crypto/helpers.md index f5bdf47650..17fc77678d 100644 --- a/docs/api/crypto/helpers.md +++ b/docs/api/crypto/helpers.md @@ -172,17 +172,3 @@ def hex_to_bytes_for_key(data: str) -> bytes Convert hex string to bytes with error handling. - - -#### generate`_`multiple`_`keys - -```python -def generate_multiple_keys(n: int, - type_: str, - password: Optional[str] = None, - extra_entropy: Union[str, bytes, int] = "", - file: Optional[str] = None) -> None -``` - -Generate n key pairs. -