Skip to content

Commit

Permalink
fix: deserialisation error due to package conflict exception string
Browse files Browse the repository at this point in the history
Ref: NRFU-1383

Signed-off-by: Krzysztof Szromek <[email protected]>
  • Loading branch information
kszromek-nordic authored and robertstypa committed Jan 9, 2025
1 parent 24dce3c commit 7cde03f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions suit_generator/suit/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def deserialize_cbor(cbstr: bytes) -> Any:
SuitObject.validate_cbor(cbstr)
try:
return cbor2.loads(cbstr)
except ImportError as err:
# Can occur due to possible incompatibilities in packages between virtual environment and system scope
# (seen on Windows, where cbor2 was installed globally and in virtual environment)
raise ValueError(
f"ImportError({err}) during data deserialisation.\n"
f" When working in virtual environment consider removing package"
f" from globally installed packages."
)
except Exception:
# Catch all exceptions since cbor2.loads raises a lot of different exceptions for invalid data:
# Payload in hex -> Exception type
Expand Down

0 comments on commit 7cde03f

Please sign in to comment.