Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check on Response being returned from form actions? #12787

Closed
brunnerh opened this issue Oct 10, 2024 · 0 comments · Fixed by #12829
Closed

Check on Response being returned from form actions? #12787

brunnerh opened this issue Oct 10, 2024 · 0 comments · Fixed by #12829
Labels
feature / enhancement New feature or request
Milestone

Comments

@brunnerh
Copy link
Member

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

@eltigerchino eltigerchino added this to the non-urgent milestone Oct 16, 2024
@eltigerchino eltigerchino added the feature / enhancement New feature or request label Oct 16, 2024
benmccann added a commit that referenced this issue Oct 25, 2024
closes #12787

Adds a check to see if the data being returned is a Response object (such as with the helper method json()), then replies with a more helpful error message.
---------

Co-authored-by: Ben McCann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants