codenotary / codenotary/immudb-py

Better exception handling

Open
#40 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
52
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Currently there is no way to get matching error code from error exception.

From my investigation:

> This exception have mainly 3 "normal" fields now
>
> ```debug_error_string {"created":"@1649922703.326925387","description":"Error received from peer ipv6:[::1]:3322","file":"src/core/lib/surface/call.cc","file_line":903,"grpc_message":"invalid user name or password","grpc_status":2}```
>
> details ```invalid user name or password```
>
> code ```StatusCode.UNKNOWN``` - it matches internal codes from GRPC, and not the code provided by server (08004)

Or in some cases
https://github.com/codenotary/immudb/blob/master/pkg/errors/map.go

>
> I looked depper into it and i see that the proper status code is in some unparsed trailing_metadata field
> ```(_Metadatum(key='grpc-status-details-bin', value=b'\x08\x02\x12\x1dinvalid user name or password\x1aE\n+type.googleapis.com/immudb.schema.ErrorInfo\x12\x16\n\x0508004\x12\rkey not found\x1a-\n+type.googleapis.com/immudb.schema.RetryInfo'),)```
>
> ```.....schema.ErrorInfo\x12\x16\n\x05------->08004<-------\x12\rkey not found\x1a-\n+type.google......```

User should have easy way to catch errors and don't compare them to string by himself.
SDK should also have some generic way to deal with Exceptions, or at least map existing error codes

https://github.com/codenotary/immudb/blob/master/pkg/errors/meta.go

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the exception behavior in the Python SDK and compare it with the referenced pkg/errors/map.go and pkg/errors/meta.go files in immudb. Investigate how grpc-status-details-bin contains the server error code and decide how the SDK should expose or map it. Done means callers can handle server error codes without comparing exception strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, python
Domain
api, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.