kit icon indicating copy to clipboard operation
kit copied to clipboard

Check on `Response` being returned from form actions?

Open brunnerh opened this issue 1 year ago • 0 comments

Describe the problem

I have seen multiple instances of json being used to try and return data from a form action. This seems like a fairly easy mistake to make and the error is not all that helpful.

Cannot stringify arbitrary non-POJOs

Describe the proposed solution

Check if the object returned from a form action is an instance of Response and give a more specific error if that is the case.

Not sure about the exact wording. Was thinking about referencing that a "plain object" should be returned, but devalue can serialize some not so plain objects as well. Maybe the message could contain a very simple example as well.

Form actions need to return objects directly and cannot wrap them in a Response.
E.g. return { success: true };

Alternatives considered

-

Importance

nice to have

Additional Information

No response

brunnerh avatar Oct 10 '24 02:10 brunnerh