parse_quantity raises decimal.Overflow instead of ValueError for some large quantities
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kubernetes-client/python
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kubernetes-client/python#2734 ·
Maintainers usually reply within 1 day
-
getheaders is deprecated in urllib3 >= 2.0.0May be free again A pull request for this issue was closed without being merged. Openkind/bug
Difficulty 1/5 Under an hour Newbie friendliness 68/100
kubernetes-client/python#2280 · 16 comments · 9 reactions ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
kubernetes-client/python#2733 · 1 comment ·
Maintainers usually reply within 1 day
-
Growing library sizeOpenhelp wanted
Difficulty 5/5 Over a week Newbie friendliness 35/100
kubernetes-client/python#2677 · 15 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Add option to disable strict x509 verifcation in sync clientPossibly taken @Vishwa0223 claimed this 49 days ago. Openhelp wanted kind/feature
kubernetes-client/python#2602 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in kubernetes-client/python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spec-kitty/spec-kitty#6112 ·
Maintainers usually reply within 1 day
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter servedPossibly taken @Mrun25 claimed this today. Openbug llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BerriAI/litellm#46095 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
uberdeveloper/fastbt#29 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
andrew-blake/melcloudhome#368 ·
Maintainers usually reply within 1 day
-
lane:discover
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SPARDiffData/differential-data-collection#33 ·
Maintainers usually reply within 1 day