Skip to content

Commit b60a778

Browse files
committed
Hotfix: Log a warning instead of failing the build when item NBT parsing fails
1 parent cf757b6 commit b60a778

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Pydantic's HISTORY.md](https://github.com/pydantic/pydantic/blob/main/HISTORY.md), and this project *mostly* adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## `1!0.1.0a23`
8+
9+
### Fixed
10+
11+
* Hotfix: Log a warning instead of failing the build when item NBT parsing fails.
12+
713
## `1!0.1.0a22`
814

915
### Changed

src/hexdoc/core/resource.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ def __repr__(self) -> str:
254254
ResLoc = ResourceLocation
255255

256256

257+
# FIXME: commas?????????????????
258+
# https://vazkiimods.github.io/Patchouli/docs/patchouli-advanced/itemstack-format
257259
@dataclass(frozen=True, repr=False)
258260
class ItemStack(BaseResourceLocation, regex=_make_regex(count=True, nbt=True)):
259261
"""Represents an item with optional count and NBT.
@@ -346,12 +348,15 @@ def _parse_nbt(nbt: str | None) -> Compound | None:
346348
if nbt is None:
347349
return None
348350

351+
# TODO: maybe re-add strict parsing when we're sure it will actually work?
349352
try:
350353
result = parse_nbt(nbt)
351-
except ValueError as e:
352-
raise ValueError(f"Failed to parse sNBT literal '{nbt}': {e}") from e
354+
except Exception as e:
355+
logger.warning(f"Failed to parse sNBT literal '{nbt}': {e}")
356+
return None
353357

354358
if not isinstance(result, Compound):
355-
raise ValueError(f"Expected Compound, got {type(result)}: {result}")
359+
logger.warning(f"Expected Compound, got {type(result)}: {result}")
360+
return None
356361

357362
return result

0 commit comments

Comments
 (0)