Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#2,735 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@KeuqS đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #2737 của @KeuqS — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kubernetes-client/python

Tất cả issue của kubernetes-client/python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.