Description
In neurons/validators/weights.py, the set_weights_subtensor function references message (and implicitly expects success) in the except branch, but both variables are only assigned inside the try block:
async def set_weights_subtensor(...):
try:
success, message = await subtensor.set_weights(...) # only assigned here
return success, message
except Exception as e:
bt.logging.error(...)
return False, message # UnboundLocalError if exception raised before assignment
If subtensor.set_weights() raises before returning, the except handler attempts to reference message which has never been defined, causing UnboundLocalError: local variable 'message' referenced before assignment.
Steps to Reproduce
Any exception raised by subtensor.set_weights() — e.g., network timeout, invalid netuid, RPC error — will trigger this code path.
Expected Behavior
The except handler returns (False, "") (or similar) gracefully.
Actual Behavior
UnboundLocalError: local variable 'message' referenced before assignment is raised instead of the intended error handling.
Fix
Initialize success = False and message = "" before the try block.
Description
In
neurons/validators/weights.py, theset_weights_subtensorfunction referencesmessage(and implicitly expectssuccess) in theexceptbranch, but both variables are only assigned inside thetryblock:If
subtensor.set_weights()raises before returning, theexcepthandler attempts to referencemessagewhich has never been defined, causingUnboundLocalError: local variable 'message' referenced before assignment.Steps to Reproduce
Any exception raised by
subtensor.set_weights()— e.g., network timeout, invalid netuid, RPC error — will trigger this code path.Expected Behavior
The except handler returns
(False, "")(or similar) gracefully.Actual Behavior
UnboundLocalError: local variable 'message' referenced before assignmentis raised instead of the intended error handling.Fix
Initialize
success = Falseandmessage = ""before thetryblock.