fix: consistent error handling for regenerate_hotkeypub and regenerate_coldkeypub#181
Open
Nicknamess96 wants to merge 1 commit intoopentensor:stagingfrom
Open
Conversation
…e_coldkeypub Map InvalidInput and KeyGeneration errors to ValueError (matching regenerate_coldkey behavior) instead of generic KeyFileError. Add tests for invalid inputs, missing args, public_key param, and file-not-found edge cases. Closes opentensor#155 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Friendly ping — this aligns the error handling in regenerate_hotkeypub and regenerate_coldkeypub to be consistent. Ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
regenerate_hotkeypub()andregenerate_coldkeypub()Python bindings now raiseValueErrorfor invalid inputs (matchingregenerate_coldkey()behavior) instead of genericKeyFileErrorProblem
regenerate_coldkey()correctly mapsWalletError::InvalidInputandWalletError::KeyGenerationtoPyValueError, butregenerate_hotkeypub()andregenerate_coldkeypub()mapped all errors generically toPyKeyFileError. This means callers catchingValueErrorfor input validation would miss errors from these two methods.Changes
src/python_bindings.rs:regenerate_coldkeypub(): replaced generic.map_err(PyErr::new::<PyKeyFileError, _>)with match onInvalidInput/KeyGeneration→PyValueError, other →PyKeyFileErrorregenerate_hotkeypub(): same fixtests/test_wallet.py:test_regenerate_hotkeypub_invalid_ss58— invalid address raises ValueErrortest_regenerate_hotkeypub_no_args— no ss58 or public_key raises ValueErrortest_regenerate_coldkeypub_invalid_ss58— same for coldkeypubtest_regenerate_coldkeypub_no_args— same for coldkeypubtest_regenerate_hotkeypub_with_public_key— regenerate via public_key workstest_hotkeypub_file_not_found— accessing hotkeypub without file raises KeyFileErrorCloses #155