Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

parse_quantity raises decimal.Overflow instead of ValueError for some large quantities

Open Beginner friendly
#2,735 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@KeuqS is already working on this.

Since Oct 12, 2026.

  • #2737 by @KeuqS — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start with kubernetes/utils/quantity.py at the reported line 85 and inspect the existing parse_quantity error handling. Reproduce the overflow with parse_quantity("2.e388635141Ki"), then check the quantity parsing tests for malformed inputs. Done when this input raises ValueError consistently and the relevant tests pass.

Written by the indexing model from the issue text.

Description

What happened (please include outputs or screenshots):

While testing an experimental version of Perch, we found the following and figured it was worth a report.

parse_quantity raises ValueError for malformed quantities, but a quantity whose exponent overflows the decimal context escapes as decimal.Overflow:

from kubernetes.utils.quantity import parse_quantity

parse_quantity("abc")
# ValueError: Invalid number format: abc

parse_quantity("2.e388635141Ki")
# decimal.Overflow: [<class 'decimal.Overflow'>]

What you expected to happen:

A ValueError, like other quantities it can't handle, so callers that catch ValueError around it keep working.

How to reproduce it (as minimally and precisely as possible):

Run the snippet above against master. No cluster is needed.

Anything else we need to know?:

It's raised at kubernetes/utils/quantity.py:85, return number * (base ** exponent). The API server won't produce a quantity this large, so in practice it shows up with hand-written or third-party manifests. Catching decimal.DecimalException there and raising ValueError would keep the error type consistent.

Environment:

  • Kubernetes version (kubectl version): not needed, no cluster involved
  • OS (e.g., MacOS 10.13.6): macOS 26.2 (arm64)
  • Python version (python --version): 3.14.2
  • Python client version (pip list | grep kubernetes): 37.0.0+snapshot (master, bb9199f7)
Dominant language
Python
Stars
7.7k
Forks
3.5k
Avg merge
1d 16h
Merged PRs (30d)
17

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kubernetes-client/python

All issues in kubernetes-client/python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.