parse_quantity raises decimal.Overflow instead of ValueError for some large quantities
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu tại kubernetes/utils/quantity.py, ở dòng 85 được báo cáo, và kiểm tra cách xử lý lỗi hiện có của parse_quantity. Tái hiện lỗi tràn số bằng parse_quantity("2.e388635141Ki"), sau đó kiểm tra các bài kiểm thử phân tích quantity với đầu vào không hợp lệ. Hoàn tất khi đầu vào này luôn gây ra ValueError và các bài kiểm thử liên quan đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- Python
- Star
- 7.7k
- Fork
- 3.5k
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của kubernetes-client/python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
kubernetes-client/python#2734 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
getheaders is deprecated in urllib3 >= 2.0.0Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởkind/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
kubernetes-client/python#2280 · 16 bình luận · 9 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
kubernetes-client/python#2733 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Growing library sizeĐang mởhelp wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
kubernetes-client/python#2677 · 15 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add option to disable strict x509 verifcation in sync clientCó thể đã có người làm @Vishwa0223 đã nhận 49 ngày trước. Đang mởhelp wanted kind/feature
kubernetes-client/python#2602 · 6 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của kubernetes-client/python
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
adri0/scadustats#128 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT` and the other `TypeDecorator`s don't declare `python_type`Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
RPBCĐang mởawaiting policy acceptance precheck-passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Bioconductor/BiocContributions#240 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue launch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
FlologixAI/etchwork#4 ·