Empty-string JSON property names are dropped during request serialization
Nobody has claimed this yet.
- 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
- Generate a Python client from the provided OpenAPI description.
- Create and send a request to POST /jobExecutions with body {"properties":{"":{}}}
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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