Skip to content

Have enhanced form action responses use HTTP status codes returned from fail #12934

@theetrain

Description

@theetrain

Describe the problem

When using <form use:enhance> to send an enhanced form action request, client-side fetch is used to request data from SvelteKit that currently is always returned with status code 200 even when return fail(400, {}) is used.

This is problematic when trying to track responses with a status of 400 (for example) using observability tools like Sentry.

Describe the proposed solution

Have the HTTP status code in a form action response match the status code of either return {} (200 or 204), or match the status code returned from fail().

This way, I can more easily track which user received which status code using observability tools. Due to the change in behaviour, I'd consider this a breaking change to SvelteKit if we proceed.

Alternatives considered

Manually log responses client-side based on response.status in use:enhance.

Importance

would make my life easier

Additional Information

Continued from: #7233 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeformsStuff relating to forms and form actions

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions