Skip to content

Multipart error handling for incorrect Content-Type #5426

@xesrevinu

Description

@xesrevinu

Description

When clients send FormData with an incorrect Content-Type header (e.g., application/json instead of multipart/form-data), the parser should return descriptive errors instead of crashing.

Fix draft

Related PR: #5425

Issues that still require further research

This debug message appears despite the MultipartError being correctly caught and returned by the test. The test passes successfully, but the log might be confusing during debugging.

timestamp=2025-08-23T08:51:42.319Z level=DEBUG fiber=#123 message="Fiber terminated with an unhandled error" cause="MultipartError: Parse
    at convertError (/Workspace/effect/packages/platform-node-shared/src/internal/multipart.ts:139:14)

Out of scope

Different error handling behavior: HttpApiSchema.MultipartStream and HttpApiSchema.Multipart handle errors differently:

  • Multipart errors are encoded as HttpApiDecodeError by default
  • MultipartStream returns MultipartError directly and requires manual error declaration

I am not sure if this is the expected behavior, maybe this should be a separate issue.

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