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

Aberta
#777 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
12/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
31
Forks
48
Merge médio
16h 36min
PRs com merge (30d)
73

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/kiota-python

Todas as issues de microsoft/kiota-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.