Skip to content

Commit

Permalink
fix: Handle IndexError when parse BinarySize (#2962) (#2964)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanghun Lee <sanghun@lablup.com>
  • Loading branch information
lablup-octodog and fregataa authored Oct 24, 2024
1 parent f68d98f commit 602cc9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/2962.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle `IndexError` when parse string to `BinarySize`
4 changes: 2 additions & 2 deletions src/ai/backend/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ def _parse_str(cls, expr: str) -> Union[BinarySize, Decimal]:
# has no suffix and is not an integer
# -> fractional bytes (e.g., 1.5 byte)
raise ValueError("Fractional bytes are not allowed")
except ArithmeticError:
raise ValueError("Unconvertible value", orig_expr)
except (ArithmeticError, IndexError):
raise ValueError("Unconvertible value", orig_expr, ending)
try:
multiplier = cls.suffix_map[suffix]
except KeyError:
Expand Down

0 comments on commit 602cc9c

Please sign in to comment.