Do not add post form body to query params if form data is only set via event#1509
Open
lukasbableck wants to merge 1 commit intohotwired:mainfrom
Open
Do not add post form body to query params if form data is only set via event#1509lukasbableck wants to merge 1 commit intohotwired:mainfrom
lukasbableck wants to merge 1 commit intohotwired:mainfrom
Conversation
m-vo
approved these changes
Feb 25, 2026
Contributor
m-vo
left a comment
There was a problem hiding this comment.
The fixed bug is really subtle as most of the time you won't realize that you're working with the reference of the actual browser URL in a turbo:submit-start event. 👍
Thanks for the fix @lukasbableck - removing the case for when the body length is 0, also makes the code much easier to understand.
ausi
approved these changes
Feb 25, 2026
fritzmg
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a scenario where you have an empty form, so no inputs and no
nameattribute on the submitter, and you're setting the form data via theturbo:submit-startevent (withevent.detail.formSubmission.fetchRequest.body.append), you're actually adding the form data to the URL objectssearchParams, asresource.searchParamsis used for the body.This causes the URL to contain all of the form data, which is especially problematic for larger amounts of data, as the webserver then might just close the connection because the URL is too long. In my case this happened after the URL reached about 7.5KB.
This PR fixes the issue, while also simplifying the logic a bit.
/cc @m-vo