microsoft / microsoft/kiota

Empty-string JSON property names are dropped during request serialization

Open
#8,163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Python status:waiting-for-triage type:bug
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Python

Describe the bug

When a request body contains an object definition, the Kiota Python client does not preserve properties whose name is an empty string ("").

The empty-string property name is valid JSON and is allowed by the OpenAPI schema. However, when the request is sent through the Kiota-generated Python client, the property is omitted from the serialized request body.

For example, the following request body:

{
  "properties": {
    "": {}
  }
}

is serialized by the Kiota Python client as:

{
  "properties": {}
}

Changing only the property name from "" to "a" causes it to be serialized correctly:

{
  "properties": {
    "a": {}
  }
}

This indicates that the empty property name is being treated differently during serialization.

Expected behavior

Kiota Python should preserve valid empty-string property names when serializing objects.

How to reproduce
  1. Generate a Python client from the provided OpenAPI description.
  2. Create and send a request to POST /jobExecutions with body {"properties":{"":{}}}
  3. Capture the outgoing HTTP request

I sent the request using

await client.job_executions.post(body=JsonParseNodeFactory().get_root_parse_node(
            "application/json",
            '{"properties": {"": {}}}'.encode()
            ).get_object_value(JobConfig))

The captured request body is {"properties": {}}

Open API description file

https://github.com/WebFuzzing/Dataset/blob/master/openapi-swagger/spring-batch-rest.json

I suspect this would work with any description that allows empty string keys in a JSON body

Kiota Version

1.35.0

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

Fedora 43

Debug output
Click to expand log ```
</details>


### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Generate a Python client from the referenced spring-batch-rest.json description and reproduce POST /jobExecutions with JsonParseNodeFactory and JobConfig using {"properties":{"":{}}}. Trace the request serialization path and compare it with the working "a" property case; done means the captured request preserves the empty-string property name.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.