fix(json): preserve empty property names during serialization - #741
Vincent Biret (baywet) merged 3 commits into
Conversation
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
CI is failing due to unit tests failing. Please have a look.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Root falsy values are still dropped during serialization.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR preserves empty-string JSON property names during serialization and adds regression coverage. A critical issue remains: falsy root values can still serialize incorrectly.
Changes:
- Distinguishes
Nonekeys from empty-string property names. - Adds tests for nested data, primitives, enums, and model collections.
| File | Summary |
|---|---|
packages/serialization/json/tests/unit/test_empty_property_names.py |
Adds regression tests for empty property names. |
packages/serialization/json/kiota_serialization_json/json_serialization_writer.py |
Updates serialization handling for empty property names. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The multipart CI failures were caused by an internal caller passing an empty string for a JSON root value. With this PR, an empty string correctly means an empty property name, so that caller produced an unwanted wrapper. Fixed in 79455e0 by passing Prepared and validated with Codex assistance. |
|




Overview
Preserve empty-string JSON property names instead of treating them as root values. For example, additional data
{"properties": {"": {}}}currently serializes as{"properties": {}}. The writer now distinguishesNone(a root value) from""(a property name), consistently across the JSON writer methods.Related Issue
Fixes #746
Testing Instructions
From
packages/serialization/json, installrequirements-dev.txtand runpytest.suggestion-modesetting in.pylintrc.Notes
AI-assisted implementation and validation. The full multi-package/Python-version CI matrix and a generated client against a live API were not run locally. Tests exercise the serializer directly, including the nested payload reported in the issue.