From 7cde03f9d87534f1eebfaae1cda5715d4299990d Mon Sep 17 00:00:00 2001 From: Krzysztof Szromek Date: Thu, 9 Jan 2025 12:24:22 +0100 Subject: [PATCH] fix: deserialisation error due to package conflict exception string Ref: NRFU-1383 Signed-off-by: Krzysztof Szromek --- suit_generator/suit/types/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/suit_generator/suit/types/common.py b/suit_generator/suit/types/common.py index 6b7ae80..e7447e7 100644 --- a/suit_generator/suit/types/common.py +++ b/suit_generator/suit/types/common.py @@ -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