Skip to content

Commit

Permalink
BACK-2735: DefaultCatchallParser skips unparsible raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
zylora committed Apr 26, 2024
1 parent 2a9b840 commit 87faddd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion offchain/metadata/parsers/catchall/default_catchall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion tests/metadata/parsers/test_default_catchall_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 87faddd

Please sign in to comment.