Python-Cardano / pycardano

A lightweight Cardano library in Python
https://pycardano.readthedocs.io
MIT License
215 stars 67 forks source link

Fix failure to report blockfrost error when cbor decode fails #386

Closed kieransimkin closed 2 days ago

kieransimkin commented 6 days ago

Sometimes the blockfrost API does not return a result set containing "result" field, so I was getting an exception out of pycardano which didn't actually show the message I was getting back from blockfrost. I've fixed this so you now get back the error from blockfrost in all circumstances.

For reference, the error I was getting was: pycardano.exception.TransactionFailedException: Namespace(fault=Namespace(code='client', string='Invalid request: Deserialisation failure while decoding serialised transaction. CBOR failed with error: DeserialiseFailure 0 "expected tag".'), reflection=Namespace(id='efc3ec98-219f-43db-9f58-a6e2ed9fbaea'), servicename='ogmios', type='jsonwsp/fault', version='1.0')

I am still not entirely sure why my cbor is failing to decode, but I'm pretty sure the problem is with my minting script (from Aiken), not pycardano :)

codecov[bot] commented 6 days ago

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.24%. Comparing base (3034cd9) to head (e333650). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pycardano/backend/blockfrost.py 0.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #386 +/- ## ========================================== - Coverage 85.30% 85.24% -0.07% ========================================== Files 32 32 Lines 4213 4216 +3 Branches 1060 1061 +1 ========================================== Hits 3594 3594 - Misses 434 437 +3 Partials 185 185 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cffls commented 6 days ago

Thanks for the fix. There is a minor issue in code format when running make qa:

pycardano/backend/blockfrost.py:313:1: W293 blank line contains whitespace

Might be easily fixable through make format.

kieransimkin commented 4 days ago

whoops, I've fixed this now :)