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 天內回覆