Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bittensor_cli/src/bittensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def normalize_hyperparameters(
norm_value = norm_value.to_dict()
else:
norm_value = value
except Exception:
except (KeyError, ValueError, TypeError, AttributeError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under which situations could an AttributeError be raised?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttributeError guards against cases where value passed to the normalization functions is None or an object lacking expected attributes (e.g., calling .rao or .tao on a malformed Balance-like object), or when norm_value unexpectedly lacks the to_dict() method. This is defensive handling since subnet hyperparameters come from chain data that may have unexpected types.

# bittensor.logging.warning(f"Error normalizing parameter '{param}': {e}")
norm_value = "-"
if not json_output:
Expand Down Expand Up @@ -1728,7 +1728,7 @@ def is_valid_github_url(url: str) -> bool:
return False

return True
except Exception: # TODO figure out the exceptions that can be raised in here
except (ValueError, TypeError, AttributeError):
return False


Expand Down
6 changes: 3 additions & 3 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async def new_hotkey(
if uri:
try:
keypair = Keypair.create_from_uri(uri)
except Exception as e:
except TypeError as e:
print_error(f"Failed to create keypair from URI {uri}: {str(e)}")
return
wallet.set_hotkey(keypair=keypair, encrypt=use_password)
Expand Down Expand Up @@ -428,7 +428,7 @@ async def new_coldkey(
if uri:
try:
keypair = Keypair.create_from_uri(uri)
except Exception as e:
except TypeError as e:
print_error(f"Failed to create keypair from URI {uri}: {str(e)}")
wallet.set_coldkey(keypair=keypair, encrypt=False, overwrite=False)
wallet.set_coldkeypub(keypair=keypair, encrypt=False, overwrite=False)
Expand Down Expand Up @@ -501,7 +501,7 @@ async def wallet_create(
"hotkey_ss58": wallet.hotkeypub.ss58_address,
"coldkey_ss58": wallet.coldkeypub.ss58_address,
}
except Exception as e:
except (ValueError, TypeError, KeyFileError) as e:
err = f"Failed to create keypair from URI: {str(e)}"
print_error(err)
output_dict["error"] = err
Expand Down