Python codegen models of custom API errors do not map `detail` onto APIError's `message` attribute
- 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?
Linux executable
### Client library/SDK language
Python
### Describe the bug
I am trying to do use custom error types that populate the "detail" field with Kiota version 1.30.0. In the generated Typescript, the `message` property of APIError gets automatically mapped to the detail attribute of the error. But this does not happen in the Python codegen.
### Expected behavior
I expect the Python codegen to behave the same as the Typescript codegen (the Message attribute of APIError should be populated by the `detail` field if present)
### How to reproduce
Run codegen on that OpenAPI schema. You'll see in the python codegen, that the ProblemDetails model's `get_field_deserializers` method doesn't do any mapping of `detail` onto `message`
Whereas in the typescript, you'll see that `message` gets set to `detail` if non-null:
`"detail": n => { problemDetails.detail = n.getStringValue(); problemDetails.message = problemDetails.detail ?? ""; },`
### Open API description file
{
"openapi": "3.1.0",
"info": { "title": "Example", "version": "0.1.0" },
"paths": {
"/api/alarms/thresholds": {
"post": {
"operationId": "create_threshold",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CreateThresholdPayload" }
}
}
},
"responses": {
"201": {
"description": "Created",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CreateThresholdResponse" }
}
}
},
"409": {
"description": "Already exists",
"content": {
"application/problem+json": {
"schema": { "$ref": "#/components/schemas/ProblemDetails" }
}
}
}
}
}
}
},
"components": {
"schemas": {
"CreateThresholdPayload": {
"type": "object",
"required": ["metricId"],
"properties": {
"metricId": { "type": "string" }
}
},
"CreateThresholdResponse": {
"type": "object",
"required": ["id"],
"properties": {
"id": { "type": "string" }
}
},
"ProblemDetails": {
"type": "object",
"required": ["title", "status", "detail", "instance"],
"properties": {
"type": { "type": "string", "default": "about:blank" },
"title": { "type": "string" },
"status": { "type": "integer" },
"detail": { "type": "string", "x-ms-primary-error-message": true },
"instance": { "type": "string" }
}
}
}
}
}
### Kiota Version
mcr.microsoft.com/openapi/kiota:1.30.0
### Latest Kiota version known to work for scenario above?(Not required)
_No response_
### Known Workarounds
_No response_
### Configuration
_No response_
### Debug output
_No response_
### Other information
_No response_
Contributor guide
Research direction
Use the supplied OpenAPI description to run the Python code generator and inspect the generated ProblemDetails model's get_field_deserializers method. Compare it with the generated TypeScript mapping for detail, then verify that the Python APIError message is populated when detail is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- api, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100