Skip to content

fix: guard handle_pat_check against ValueError for unregistered hotkeys#383

Closed
Grizouforever wants to merge 1 commit intoentrius:testfrom
Grizouforever:fix/clean-pat-handler-guard
Closed

fix: guard handle_pat_check against ValueError for unregistered hotkeys#383
Grizouforever wants to merge 1 commit intoentrius:testfrom
Grizouforever:fix/clean-pat-handler-guard

Conversation

@Grizouforever
Copy link
Copy Markdown

Summary

  • Add hotkey registration check at the top of handle_pat_check in pat_handler.py
  • Without this guard, metagraph.hotkeys.index(hotkey) raises an uncaught ValueError when an unregistered caller reaches the handler
  • Add a corresponding test test_unregistered_hotkey_returns_no_pat

Related Issues

Fixes #376

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

  • Tests added/updated
  • Manually tested

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

cc @anderdc @LandynDev for review

handle_pat_check called metagraph.hotkeys.index(hotkey) without first
checking whether the hotkey is registered, raising an uncaught ValueError
when an unregistered caller hits the endpoint. Add an early-exit guard
that mirrors the blacklist handler, and add a test for this path.
@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 12, 2026

The blacklist function runs before the handler. If the hotkey isn't registered, the synapse gets rejected at the blacklist layer and handle_pat_check is never called. Thus this bug/issue never happens in production

@anderdc anderdc closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: handle_pat_check raises unhandled ValueError when hotkey deregisters between blacklist and handler

2 participants