RFC 9457 Problem Details for HttpApi errors
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- backend-api-design
Línea de trabajo
Start with packages/effect/src/http-api/HttpApiError.ts and the existing HttpApi middleware, schema, OpenAPI, and client paths named in the proposal. Review linked pull request #9706 and issue #5367 before considering scope; the issue leaves package placement and decode disclosure open. Done means implementing the proposed Problem Details schema, typed errors, opt-in rendering, OpenAPI support, and client decoding while preserving the default empty-body behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
RFC 9457 (application/problem+json) is the standard JSON format for HTTP API errors. HttpApi doesn't support it, and by default its errors have no body:
- The built-in errors (
HttpApiError.BadRequest,NotFound, and so on) are sent as empty responses (packages/effect/src/http-api/HttpApiError.ts:23-56). - When a request fails to decode, the server answers with an empty
400(HttpApiError.ts:507). The client gets no indication of which field was wrong or why.
You can build Problem Details yourself with HttpApiMiddleware.layerSchemaErrorTransform and HttpApiSchema.asJson({ contentType }). But every project then writes its own schema, picks its own type, title and status defaults, and has to get the RFC's parsing rules right. For example, §3.1 says a member with the wrong JSON type is ignored, not rejected. #5367 asked for this in v3 and was closed with a workaround that re-encoded response bodies in a middleware. The people in that thread noted that the OpenAPI output then had to be patched as well.
Proposal
- A
ProblemDetailsvalue and Schema:typedefaults toabout:blank.status,title,detailandinstanceare optional.- Unknown members are kept as extensions.
- It decodes leniently, as §3.1 requires, and encodes canonically.
- A way to declare a typed problem: a fixed
typeURI with typed extension members, usable as an HttpApi error schema with the right status, media type and OpenAPI entry.
- An opt-in that renders HttpApi's own errors (decode failures and the built-ins) as Problem Details.
HttpApiClientdecodesapplication/problem+jsonresponses into the declared problem type.
// names illustrative
class OutOfCredit extends ProblemDetails.Type("https://example.com/probs/out-of-credit", {
status: 403,
balance: Schema.Number
}) {}
HttpApiEndpoint.post("buy", "/buy", { error: OutOfCredit })
Why in Effect
HttpApi owns both the mapping from errors to responses and the OpenAPI output, so this is the one place where it can be done without post-processing bodies and patching the spec. The format is widely supported elsewhere: ASP.NET Core (AddProblemDetails), Spring (ProblemDetail), and Rust's http-api-problem crate.
Scope
In scope:
- The value and Schema, typed problems, opt-in rendering, OpenAPI output and client decoding.
Out of scope:
application/problem+xml.- Changing the default empty-body behaviour without an opt-in.
Open questions
- Should this live in
effect/http, so it can be used without HttpApi, or ineffect/http-api? - How much should a decode failure reveal by default? The failing path and message help clients, but they also expose details of the schema.
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 10 h 7 min
- PR fusionados (30 d)
- 808
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 Effect-TS/effect
-
Support {self: this} for fnUntracedPosiblemente ocupada @ArjunCodess la tomó hace 32 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Effect-TS/effect#8101 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
v4 Cache.get: a caller that joins an abandoned lookup fails with an interruption it did not ask forAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Los mantenedores suelen responder en 1 día
-
Typed unix socket and TLS options for `BunHttpClient` and `DenoHttpClient`Posiblemente ocupada @effect-bot la tomó hoy. Abiertodocker-made-me-do-it enhancement platform
Effect-TS/effect#9687 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Typed parsers and formatters for common HTTP header valuesPosiblemente ocupada @effect-bot la tomó hoy. Abiertodocker-made-me-do-it enhancement
Effect-TS/effect#9685 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
paperclipai/paperclip#17151 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
AgoraIO-Extensions/agent-infra#3159 ·
Los mantenedores suelen responder en 1 día
-
blocklist addition
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
MetaMask/eth-phishing-detect#304596 ·
Los mantenedores suelen responder en 1 día
-
friction
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
kentcdodds/kody#4142 ·
-
[Bug] Statistics | Task statistics are always empty on MikroORM with MySQL or SQLitePosiblemente ocupada @NdekoCode la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ever-co/ever-gauzy#11214 ·
Los mantenedores suelen responder en 1 día