Skip to content

use message failure responses - #7787

Draft
ivan-klass wants to merge 1 commit into
http4s:series/0.23from
ivan-klass:message-failure-responses
Draft

ivan-klass wants to merge 1 commit into
http4s:series/0.23from
ivan-klass:message-failure-responses

Conversation

@ivan-klass

@ivan-klass ivan-klass commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

I'm trying to migrate tapir http4s server examples and tests from blaze to ember here.
It seems that in ember the handling of MessageFailure is missing

@mergify mergify Bot added series/0.23 PRs targeting 0.23.x module:ember-server labels Feb 17, 2026
@ivan-klass
ivan-klass force-pushed the message-failure-responses branch from 4a33812 to a23316c Compare February 17, 2026 21:30
badRequest.covary[F]
.recover {
case Parser.HeaderP.ParseHeadersError(_) => badRequest.covary[F]
case mf: MessageFailure => mf.toHttpResponse[F](req.httpVersion)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried using org.http4s.server.middleware.ErrorHandling? It's usually the standard way to add error handling to your server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, speaking of the Blaze implementation, I'm not sure whether Blaze specifically handles MessageFailure internally. What particular difference in behavior are you seeing?

@ivan-klass ivan-klass Feb 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danicheg in tapir we're testing different backends (interpreters) for both server and clients.

In tapir http endpoints are described in special DSL types. There are scala types for payload format - e.g. json, form, multipart. Later special typeclasses (like sttp.tapir.Codec) will be provided by corresponding integration modules (say, something like "tapir-http4-circe").
So, by using a http4s interpreter, the list of implemented tapir endpoints becomes a http4s.HttpApp that can be mounted to the http4s server, and some kind of default server config is used in tests. I'm trying to switch all Blaze to Ember in all the tests and examples.

For different interpreters there are tests for invalid client payloads, specifically for bad request status if It's a bad multipart or json format.
It uses EntityEncoders under the hood for http4s.
It looks like these tests are not passing because the logic provided by the PR is missing in Ember http app mounting, compared to Blaze

@ivan-klass ivan-klass Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danicheg I've found that in Blaze builder defaults the

DefaultServiceErrorHandler is used

which handles message failures (see here).

May we have something similar in EmberServerBuilder.Defaults.errorHandler ?
The problem is that we don't have request.httpVersion at hand, it's only Throwable as input.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried to override the default error handler in the server builder (using org.http4s.ember.server.EmberServerBuilder#withErrorHandler)?

@ivan-klass
ivan-klass marked this pull request as draft July 26, 2026 09:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants