JSON numeric getters accept booleans as integers and floats
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 JSON 解析节点实现中的 JsonParseNode.get_int_value() 和 get_float_value() 开始,然后追踪类型化原始值集合如何转换每个元素。为直接值、由 JsonParseNodeFactory 解析的子节点以及显式指定类型的集合添加回归测试;保留布尔 getter、有效的数值转换和推断出的布尔集合。完成标准是布尔值从数值 getter 返回 None,并且针对性回归测试和现有对照测试均通过。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
JsonParseNode.get_int_value() accepts JSON booleans as integers, and get_float_value() converts them to 1.0/0.0. This also occurs through child nodes parsed from JSON bytes and in explicitly typed numeric collections.
The implementation uses isinstance(value, int) / isinstance(value, (float, int)). In Python, bool is a subclass of int, but JSON booleans are not numeric tokens. Other non-number values already return None from these getters.
Reproduction
from kiota_serialization_json.json_parse_node import JsonParseNode
from kiota_serialization_json.json_parse_node_factory import JsonParseNodeFactory
print(JsonParseNode(True).get_int_value()) # True
print(JsonParseNode(False).get_float_value()) # 0.0
root = JsonParseNodeFactory().get_root_parse_node(
"application/json", b'{"count": true}'
)
print(root.get_child_node("count").get_int_value()) # True
print(JsonParseNode([1, True, False, 0]).get_collection_of_primitive_values(float))
# [1.0, 1.0, 0.0, 0.0]
Expected behavior
Boolean inputs should follow the existing non-number path and return None from integer/float getters, rather than silently becoming numbers. Numeric collection conversion should use the same element conversion behavior it already uses for other non-numeric values. The actual boolean getter, valid integers/floats, integer-to-float conversion, and inferred boolean collections should remain unchanged.
This is not a request to redesign primitive collection nullability (#777), change public signatures, or change JSON writer behavior.
Environment and validation
- Current main: ee58dcf.
- Python 3.14.5, Windows; editable local JSON/abstractions packages.
- Added scalar, real JSON factory/child, and typed collection regressions: 12 failures on unchanged source; focused run also has 20 passing controls/existing tests.
- No production traffic or external API credentials involved.
Discovered through source review and reproduced locally with AI assistance. I can provide the focused parser fix and regression tests.
- 主要语言
- Python
- 星标
- 31
- 派生
- 48
- 平均合并
- 16 小时 36 分钟
- 30 天内合并 PR
- 73
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/kiota-python 的其他 Issue
-
Backing store enumeration returns internal tracking tuples instead of stored lists可能已有人在做 @pradeep-ramola 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/kiota-python#938 ·
维护者通常 1 天内回复
-
ensure 304 response code does not throw可能重新可做 @nightcityblade 于 92 天前认领,目前没有进行中的 PR。 未关闭help wanted type:bug
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/kiota-python#477 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
microsoft/kiota-python#901 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 18/100
microsoft/kiota-python#898 ·
维护者通常 1 天内回复
-
type:breaking-change
难度 5/5 一周以上 新手友好度 12/100
microsoft/kiota-python#777 · 2 条评论 ·
维护者通常 1 天内回复
查看 microsoft/kiota-python 的全部 Issue
相似的 Issue
-
backend: claude chore dependencies
难度 2/5 1-3 小时 新手友好度 72/100
briandconnelly/amicus#606 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
semantica-agi/semantica#2320 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
vllm-project/vllm-omni#11465 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
jxxghp/MoviePilot#7699 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
vllm-project/vllm-ascend#24010 ·
维护者通常 1 天内回复