JSON deserialization does not handle OverflowError
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
从 packages/serialization/json/kiota_serialization_json/json_parse_node.py 中的 JsonParseNode.try_get_anything() 以及 parse_timedelta_string() 周围的 catch 开始。重现输入 "50001140846:00021",并检查 issue 中提到的其他 catch 处理程序。完成的标准是:格式错误的值原样传递,不会产生未捕获的 OverflowError。
由索引模型根据 Issue 内容生成。
描述
Trying to deserialize certain misformatted strings result in an uncaught OverflowError exception instead of passing through the string unchanged. In particular, trying to deserialize a timedelta string such as "50001140846:00021" results in the following:
Traceback (most recent call last):
File "lib\site-packages\kiota_abstractions\date_utils.py", line 66, in parse_timedelta_string
return parse_timedelta_from_iso_format(text)
File "lib\site-packages\kiota_abstractions\date_utils.py", line 34, in parse_timedelta_from_iso_format
raise ValueError(f"Invalid ISO8601 duration string: {text}")
ValueError: Invalid ISO8601 duration string: 50001140846:00021
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
[...]
File "lib\site-packages\kiota_serialization_json\json_parse_node.py", line 335, in try_get_anything
return parse_timedelta_string(value)
File "lib\site-packages\kiota_abstractions\date_utils.py", line 76, in parse_timedelta_string
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
OverflowError: days=2083380868; must have magnitude <= 999999999
The issue is that JsonParseNode.try_get_anything() only handles ValueError exceptions instead of also handling OverflowError. Changing this line to catch both ValueError and OverflowError allows deserialization to be successful:
https://github.com/microsoft/kiota-python/blob/b23edcbf268efdb81d14ef59cecc6c9565288248/packages/serialization/json/kiota_serialization_json/json_parse_node.py#L336
Most likely the other catch handlers in try_get_anything() should be updated as well.
- 主要语言
- Python
- 星标
- 31
- 派生
- 40
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 28
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/kiota-python 的其他 Issue
-
help wanted type:bug
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/kiota-python#477 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
microsoft/kiota-python#745 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
microsoft/kiota-python#744 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
microsoft/kiota-python#737 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/kiota-python#722 · 2 条评论 ·
维护者通常 1 天内回复
查看 microsoft/kiota-python 的全部 Issue
相似的 Issue
-
feature:LinkChecker
难度 2/5 1-3 小时 新手友好度 66/100
digitalfabrik/integreat-cms#4594 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
EleutherAI/lm-evaluation-harness#4319 ·
维护者通常 1 天内回复
-
needs triage
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")可能已有人在做 @mayureshsonawane17 今天认领。 未关闭Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 5 天内回复