Skip to content

nil pointer if request id of incorrect length #79

@MastaP

Description

@MastaP
{"time":"2025-11-04T15:29:24.390826374Z","level":"DEBUG","msg":"JSON-RPC request completed","method":"submit_commitment","request_id":"7e379a22-6145-4be9-ad37-18dfccda7e88","duration_ms":27}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x130c0ef]

goroutine 1742 [running]:
github.com/unicitynetwork/aggregator-go/internal/service.(*AggregatorService).GetInclusionProof(0xc00072c500, {0x20cf9c0, 0xc0002e04d0}, 0xc000cf7080)
        /app/internal/service/service.go:202 +0x1af
github.com/unicitynetwork/aggregator-go/internal/gateway.(*Server).handleGetInclusionProof(0xc000734300, {0x20cf9c0, 0xc0002e04d0}, {0xc000e1a190, 0x50, 0x50})
        /app/internal/gateway/handlers.go:51 +0xcc
github.com/unicitynetwork/aggregator-go/pkg/jsonrpc.(*Server).handleRequest(0xc00072c550, {0x20cf9c0, 0xc0002e04d0}, 0xc000c98910)
        /app/pkg/jsonrpc/handler.go:134 +0x129
github.com/unicitynetwork/aggregator-go/pkg/jsonrpc.(*Server).processRequest.func1({0x20cf9c0?, 0xc0002e04d0?}, 0xc000cf4120?)
        /app/pkg/jsonrpc/handler.go:108 +0x2d
github.com/unicitynetwork/aggregator-go/internal/gateway.(*Server).setupJSONRPCHandlers.TimeoutMiddleware.func3.1()
        /app/pkg/jsonrpc/handler.go:218 +0x2f
created by github.com/unicitynetwork/aggregator-go/internal/gateway.(*Server).setupJSONRPCHandlers.TimeoutMiddleware.func3 in goroutine 1754
        /app/pkg/jsonrpc/handler.go:217 +0x111

The following code should return error:

func (smt *SparseMerkleTree) GetPath(path *big.Int) *api.MerkleTreePath {
	if path.BitLen()-1 != smt.keyLength {
		// TODO: better error handling
		fmt.Printf("SparseMerkleTree.GetPath(): invalid key length %d, should be %d", path.BitLen()-1, smt.keyLength)
		return nil
	}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

In Dev

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions