Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

JSON deserialization does not handle OverflowError

未关闭
#480 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@HardMax71 已经在做这个了。

开始于 2026年10月3日。

  • #760 来自 @HardMax71 —— 未关闭

评估

难度
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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/kiota-python 的其他 Issue

查看 microsoft/kiota-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。