Skip to content
New issue

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

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

Already on GitHub? # to your account

Prevent 500 return code on empty post request to bulk routes #3647

Merged

Conversation

jnoordsij
Copy link
Contributor

When posting with empty body to bulk routes, a 500 HTTP code is returned as $entries will be null, hence cannot be called in a foreach loop.

Other POST (and PUT/DELETE) routes return a 302 / 200 HTTP code on empty bodies. I think this is a better default response to aim for, as it allows for easier feature testing on accessibility of routes.

@pxpm
Copy link
Contributor

pxpm commented Apr 5, 2021

Hello @jnoordsij

Can you let me know how would you send empty body ? clone and delete bulk buttons are disabled when nothing is ticked in the checkboxes ?

I tried also with an empty table just trying to select all and it still don't enable the buttons if nothing is selected.

Thanks,
Pedro

@jnoordsij
Copy link
Contributor Author

There is actually no way in the standard user interface; only if you override the view manually or (like me) try to post to this route in a feature test, you can actually achieve this.

@pxpm
Copy link
Contributor

pxpm commented Apr 7, 2021

Got it @jnoordsij

Thanks again 👼

@pxpm pxpm self-requested a review April 7, 2021 11:05
Copy link
Contributor

@pxpm pxpm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tabacitu tabacitu merged commit 4d05f98 into Laravel-Backpack:master Apr 16, 2021
@jnoordsij jnoordsij deleted the prevent-error-on-bulk-operations branch December 6, 2021 10:24
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants