Skip to content

Commit 87faddd

Browse files
committed
BACK-2735: DefaultCatchallParser skips unparsible raw data
1 parent 2a9b840 commit 87faddd

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v0.3.3
44

55
- Fix an issue in `OpenseaParser` where the plain-text svg wouldn't be recognized as valid image uri
6+
- Add check in `DefaultCatchallParser` to require that `raw_data` be a `dict`
67

78
## v0.3.2
89

offchain/metadata/parsers/catchall/default_catchall.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,7 @@ def should_parse_token( # type: ignore[no-untyped-def]
242242
Returns:
243243
bool: whether or not the collection parser handles this token.
244244
"""
245-
return bool(token.uri and raw_data)
245+
246+
if raw_data is not None and not isinstance(raw_data, dict):
247+
logger.info("DefaultCatchallParser skips token {token} due to invalid raw data")
248+
return bool(token.uri and raw_data is not None and isinstance(raw_data, dict))

tests/metadata/parsers/test_default_catchall_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from offchain.metadata.fetchers.metadata_fetcher import MetadataFetcher
8-
from offchain.metadata.models.metadata import Metadata, MetadataStandard
8+
from offchain.metadata.models.metadata import Metadata
99
from offchain.metadata.models.token import Token
1010
from offchain.metadata.parsers.catchall.default_catchall import DefaultCatchallParser
1111

0 commit comments

Comments
 (0)