Primitive and enum collections contain None despite non-nullable element annotations

オープン
#777 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
12/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
活発
技術スタック
python
領域
devtools

調査の方向性

Start with get_collection_of_primitive_values and get_collection_of_enum_values in packages/serialization/json/kiota_serialization_json/json_parse_node.py, plus the nullable converters below them, and compare them with the public contracts in packages/abstractions/kiota_abstractions/serialization/parse_node.py. The issue asks maintainers to choose between widening the annotations and rejecting nulls, so agree on that direction before editing. Done means a decision is recorded and tests cover nulls, wrong shapes, temporal failures and array-versus-CSV enum behaviour.

索引モデルが issue の本文から書いたものです。

説明

type:breaking-change

Problem

Optional[list[T]] permits an absent collection, not None elements. JSON primitive and enum collection readers retain nullable conversion results, while generated properties expose non-nullable elements.

Reproduction

import json
from enum import Enum
from kiota_serialization_json.json_parse_node import JsonParseNode

JsonParseNode(json.loads('["a", null, 42]')).get_collection_of_primitive_values(str)
# ["a", None, None], despite Optional[list[str]]

class Colour(Enum):
    Red = "red"

JsonParseNode(json.loads('["red", null, "unknown"]')).get_collection_of_enum_values(Colour)
# [Colour.Red, None, None]

These reproductions are source-derived. CSV enum parsing filters unsuccessful results, unlike enum array parsing. Some malformed temporal/UUID values throw while other conversions return None. Model factories normally create empty models for JSON null; they are not included in this confirmed mismatch.

Source

Expected resolution and breaking impact

Either reflect nullable elements in abstractions, implementations and generated models, or reject null/unsuccessful conversions when promising non-nullable elements. Widening annotations is source-breaking; throwing changes behavior. Avoid casts that hide the mismatch or silent filtering of position-sensitive arrays. Cover nulls, wrong primitive shapes, temporal conversion failures and array-versus-CSV enum behavior. Coordinate runtime and generator releases.

Related cross-language audit: microsoft/kiota#8377.

主要言語
Python
スター
31
フォーク
48
平均マージ
16時間 36分
マージ済み PR(30日)
73

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/kiota-python のほかの issue

microsoft/kiota-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。