immudb icon indicating copy to clipboard operation
immudb copied to clipboard

gRPC API doesn't set correct codes in error response

Open arturmelanchyk opened this issue 2 years ago • 0 comments

What happened In response to a VerifiableGet request I received gRPC error "key not found" and it's code was set to 2, which stands for Unknown

What you expected to happen gRPC error code should have been set to 5 NotFound

How to reproduce it (as minimally and precisely as possible) Call VerifiableGet with non-existing key argument

Additional info (any other context about the problem) The problem is that VerifiableGet in db_operations.go has to return gRPC error using status.Error(codes.NotFound, "key not found") with correct code set instead of immediately returning err to the caller. Otherwise code will be implicitly set to "Unknown" https://github.com/codenotary/immudb/blob/2b6c5b03aaa610965f632775e225175666ee7951/pkg/server/db_operations.go#L84-L118

arturmelanchyk avatar Jun 28 '22 11:06 arturmelanchyk