Skip to content

Conversation

@jait91
Copy link
Contributor

@jait91 jait91 commented Nov 19, 2025

fixes #79

@jait91 jait91 requested a review from MastaP November 19, 2025 17:00
@jait91 jait91 added this to Unicity Nov 19, 2025
@jait91 jait91 added the bug Something isn't working label Nov 19, 2025
Copy link
Contributor

Copilot AI left a 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 TimeoutMiddleware to 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 to ThreadSafeSMT to 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.

@mareksepp mareksepp moved this to Todo in Unicity Nov 20, 2025
@jait91 jait91 requested a review from MastaP December 9, 2025 07:51
@jait91 jait91 moved this from Todo to Test in Unicity Dec 9, 2025
@b3y0urs3lf b3y0urs3lf moved this from Test to Blocked in Unicity Dec 11, 2025
@MastaP MastaP moved this from Blocked to Test in Unicity Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Test

Development

Successfully merging this pull request may close these issues.

nil pointer if request id of incorrect length

4 participants