Skip to content

HttpApiSchemaError is reported as a failure though it answers 400 #8696

Closed

Description

@peterje

HttpApiSchemaError responds with 400 Bad Request, but unlike the other client errors in effect/http-api/HttpApiError (BadRequest, NotFound, Unauthorized, ...) it does not set [ErrorReporter.ignore] = true. Error reporters therefore treat every request that fails schema validation as a server-side failure.

In practice this floods logs: a host that logs unreported causes (Alchemy's Cloudflare Workers adapter, alchemy/src/Http.ts, logs "HTTP handler failed" at error level for any cause not marked ignored) prints a full error for each malformed request, even though the client simply sent bad input and received the documented 400.

// [email protected], packages/effect/src/http-api/HttpApiError.ts (also on main, 5e6f7568a4)
export class HttpApiSchemaError extends Data.TaggedClass("HttpApiSchemaError")<{ ... }> {
  // no [ErrorReporter.ignore] = true, while BadRequest/NotFound/... declare it
  [HttpServerRespondable.symbol]() { return Effect.succeed(badRequestResponse) }
}

Reproduce: serve an HttpApi endpoint with a payload schema, POST an invalid body, and observe the 400 response alongside an error report for the same request.

Suggested fix: add readonly [ErrorReporter.ignore] = true to HttpApiSchemaError, matching the other 4xx error classes.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions