diff --git a/docs/changelog.md b/docs/changelog.md index cdd2bf8..8876290 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,7 @@ ## v0.3.3 - Fix an issue in `OpenseaParser` where the plain-text svg wouldn't be recognized as valid image uri +- Add check in `DefaultCatchallParser` to require that `raw_data` be a `dict` ## v0.3.2 diff --git a/offchain/metadata/parsers/catchall/default_catchall.py b/offchain/metadata/parsers/catchall/default_catchall.py index 43f9fa4..0bdda1e 100644 --- a/offchain/metadata/parsers/catchall/default_catchall.py +++ b/offchain/metadata/parsers/catchall/default_catchall.py @@ -242,4 +242,7 @@ def should_parse_token( # type: ignore[no-untyped-def] Returns: bool: whether or not the collection parser handles this token. """ - return bool(token.uri and raw_data) + + if raw_data is not None and not isinstance(raw_data, dict): + logger.info("DefaultCatchallParser skips token {token} due to invalid raw data") + return bool(token.uri and raw_data is not None and isinstance(raw_data, dict)) diff --git a/tests/metadata/parsers/test_default_catchall_parser.py b/tests/metadata/parsers/test_default_catchall_parser.py index 39b0d5f..dcdef25 100644 --- a/tests/metadata/parsers/test_default_catchall_parser.py +++ b/tests/metadata/parsers/test_default_catchall_parser.py @@ -5,7 +5,7 @@ import pytest from offchain.metadata.fetchers.metadata_fetcher import MetadataFetcher -from offchain.metadata.models.metadata import Metadata, MetadataStandard +from offchain.metadata.models.metadata import Metadata from offchain.metadata.models.token import Token from offchain.metadata.parsers.catchall.default_catchall import DefaultCatchallParser