parse_quantity raises decimal.Overflow instead of ValueError for some large quantities
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从报告所指的第85行 kubernetes/utils/quantity.py 开始,检查现有的 parse_quantity 错误处理。使用 parse_quantity("2.e388635141Ki") 重现溢出,然后检查 quantity 解析测试中对格式错误输入的测试。当此输入始终引发 ValueError 且相关测试通过时,即为完成。
由索引模型根据 Issue 内容生成。
描述
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)
- 主要语言
- Python
- 星标
- 7.7k
- 派生
- 3.5k
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kubernetes-client/python 的其他 Issue
-
Websocket proxy auth truncates passwords that contain a colon可能已有人在做 @Akshaay1 于 1 天前认领。 未关闭help wanted
难度 2/5 1-3 小时 新手友好度 86/100
kubernetes-client/python#2734 · 3 条评论 ·
维护者通常 1 天内回复
-
getheaders is deprecated in urllib3 >= 2.0.0可能重新可做 关联的 PR 已关闭且未合并。 未关闭kind/bug
难度 1/5 1 小时以内 新手友好度 68/100
kubernetes-client/python#2280 · 16 条评论 · 9 个 reaction ·
维护者通常 1 天内回复
-
kind/feature
难度 2/5 1-3 小时 新手友好度 55/100
kubernetes-client/python#2739 ·
维护者通常 1 天内回复
-
kind/bug
难度 2/5 1-3 小时 新手友好度 35/100
kubernetes-client/python#2733 · 3 条评论 ·
维护者通常 1 天内回复
-
help wanted
难度 5/5 一周以上 新手友好度 35/100
kubernetes-client/python#2677 · 15 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 kubernetes-client/python 的全部 Issue
相似的 Issue
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunk可能已有人在做 @rodricksz4h5 今天认领。 未关闭area/streaming comp/gateway P2 type/security
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#138245 ·
维护者通常 1 天内回复
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS step可能已有人在做 @github-actions 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
correction metadata
难度 2/5 1 小时以内 新手友好度 68/100
acl-org/acl-anthology#10378 · 1 条评论 ·
维护者通常 1 天内回复
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom name可能已有人在做 @12YYCCYY16 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
prowler-cloud/prowler#13033 ·
维护者通常 1 天内回复
-
enhancement
难度 1/5 1-3 小时 新手友好度 88/100
graygarbage/HermesKey#23 ·