[BUG][csharp][restsharp] throwOnAnyError: oneOf/anyOf deserialization failure on 2xx escapes as InvalidDataException instead of ApiException
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 65/100
Línea de trabajo
Empieza en modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache cerca de la línea 500 y sigue la llamada FromJson y el tratamiento existente de throwOnAnyError. Reproduce el problema con un cliente RestSharp generado que use una respuesta oneOf o anyOf que no coincida con ninguna variante y una respuesta 200. El objetivo se alcanza cuando el error de análisis llega a quien llama como una ApiException que contiene el estado 200, el cuerpo sin procesar, los encabezados y la InvalidDataException como excepción interna.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
With throwOnAnyError=true the generated ApiClient promises that every failure surfaces as ApiException. For a 2xx response whose body matches none of the oneOf/anyOf variants, FromJson throws InvalidDataException after the ErrorException guard has already passed, so the raw exception reaches the caller without status code, body or headers.
openapi-generator version
master (after #25217)
Steps to reproduce
- Generate a csharp client with
--library restsharp --additional-properties throwOnAnyError=truefrom a spec where an operation returns aoneOfmodel. - Call that operation against a server that returns 200 with a body matching no variant.
- Observe
InvalidDataExceptioninstead ofApiException.
Expected behaviour
ApiException with ErrorCode = 200, ErrorContent = raw body, Headers populated, and the InvalidDataException as InnerException.
Original findings
P2: The
FromJsoncall below can throwInvalidDataExceptionfor a 2xx body that matches no oneOf/anyOf schema, after this check has passed; the raw exception escapes instead of the promisedApiException. Wrap that parse failure with the response status, content, and headers.Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache, line 500: <comment>The `FromJson` call below can throw `InvalidDataException` for a 2xx body that matches no oneOf/anyOf schema, after this check has passed; the raw exception escapes instead of the promised `ApiException`. Wrap that parse failure with the response status, content, and headers.</comment> <file context> @@ -495,6 +494,14 @@ namespace {{packageName}}.Client + {{#throwOnAnyError}} + + // 4xx/5xx also carry ErrorException; those go through ExceptionFactory so the body is kept + if (response.ErrorException != null && (int)response.StatusCode < 400) + { + throw new ApiException((int)response.StatusCode, string.Format("Error calling {0}: {1}", request.Resource, response.ErrorMessage), response.Content, ToApiResponse(response).Headers); </file context>
Originally posted by @cubic-dev-ai[bot] in #25217
- Lenguaje dominante
- Java
- Estrellas
- 26.8k
- Forks
- 7.7k
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 141
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenAPITools/openapi-generator
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenAPITools/openapi-generator#25237 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenAPITools/openapi-generator#25236 ·
Los mantenedores suelen responder en 1 día
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)Posiblemente ocupada @mohitduhan19 la tomó hace 1 día. AbiertoIssue: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenAPITools/openapi-generator#25233 ·
Los mantenedores suelen responder en 1 día
-
[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabledPosiblemente ocupada @mohitduhan19 la tomó hace 1 día. AbiertoIssue: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
OpenAPITools/openapi-generator#25232 ·
Los mantenedores suelen responder en 1 día
-
[BUG][KOTLIN] multiplatform/jvm-ktor: `DELETE` without `requestBody` sends `"Content-Type: application/json"` with an empty bodyPosiblemente ocupada @mohitduhan19 la tomó hace 1 día. AbiertoIssue: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenAPITools/openapi-generator#25223 ·
Los mantenedores suelen responder en 1 día
Todos los issues de OpenAPITools/openapi-generator
Issues similares
-
Status: Pending Review Type: Feature Request
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
OpenRefine/OpenRefine#8019 ·
Los mantenedores suelen responder en 1 día
-
`timer` rule rejects dates the engine acceptsPosiblemente ocupada @MFA-G la tomó hoy. Abiertobug ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
camunda/bpmnlint-plugin-camunda-compat#281 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día