-
Notifications
You must be signed in to change notification settings - Fork 0
add panic recovery for requests and better validation #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds panic recovery for JSON-RPC request handlers and improves validation for inclusion proof requests. The changes help prevent server crashes from panicked handlers while also providing better error messages for invalid requests.
- Added panic recovery in
TimeoutMiddlewareto gracefully handle panics during request processing - Added validation to check path length matches SMT key length before attempting to retrieve inclusion proofs
- Added
GetKeyLength()method toThreadSafeSMTto enable validation of request paths
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/jsonrpc/handler.go | Adds panic recovery with deferred recover() to catch panics in goroutine and return proper error response |
| pkg/jsonrpc/handler_test.go | Adds test to verify panic recovery returns appropriate error response |
| internal/smt/thread_safe_smt.go | Adds thread-safe GetKeyLength() method to expose SMT key length for validation |
| internal/service/service.go | Adds nil check for SMT instance and validates request path length matches SMT key length before processing |
| internal/service/service_test.go | Adds comprehensive tests for shard mismatch, invalid format, unavailable SMT, and invalid path length scenarios; removes redundant nil check in validation helper |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixes #79