fix(dice): parse_dice validates sides >= _MIN_SIDES so d1/1d1 raise DiceParseError instead of leaking the model validator's pydantic ValidationError; drop the dead not-sides_str guard (regex \\d+ already guarantees non-empty) + 3 rejected-notation cases (d1, 1d1, 2D6)

This commit is contained in:
2026-09-19 18:51:38 +02:00
parent bdf15aa8fe
commit e8b7a73d1f
2 changed files with 4 additions and 3 deletions
+1 -3
View File
@@ -103,15 +103,13 @@ def parse_dice(text: str) -> DiceExpr:
m = _DICE_RE.match(stripped)
if m:
count_str, sides_str, bonus_str = m.groups()
if not sides_str:
raise DiceParseError(text)
count = int(count_str) if count_str else 1
sides = int(sides_str)
bonus = int(bonus_str) if bonus_str else 0
if count == 0:
raise DiceParseError(text)
if sides < 1:
if sides < _MIN_SIDES:
raise DiceParseError(text)
return DiceExpr(count=count, sides=sides, bonus=bonus)