feat: allow overriding HTTP parser body length via env var - #265
Merged
Conversation
ngdangdat
marked this pull request as ready for review
April 29, 2026 09:07
Contributor
Author
|
Hi @Clivern, Please help to review the PR when you have time. I'm facing this issue when using Lynx in my production environment 🙇 tofu apply
...
Acquiring state lock. This may take a few moments...
Failed to persist state: HTTP error: 413Thank you in advance! |
Owner
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.
Summary
Make
Plug.Parsers's:lengthconfigurable viaAPP_HTTP_MAX_BODY_LENGTH(defaults to the current 8 MB).Reference:
Plug.Parsers— Options —:lengthsets the maximum body length the parser accepts; it defaults to8_000_000bytes.Why
Pushing a Terraform state larger than 8 MB fails with:
The
errored.tfstateis exactly 8.0M, which tripsPlug.Parsers's default:lengthof8_000_000bytes inlib/lynx_web/endpoint.ex:52. State files in real-world projects routinely grow past that, so the cap needs to be tunable per-deployment.Change
Wired the limit through application config (sitting next to the existing
LynxWeb.Endpointconfig keys, matching theAPP_HOSTpattern already there):Default behavior is unchanged. Operators bumping into 413s can set e.g.
APP_HTTP_MAX_BODY_LENGTH=104857600for 100 MB before building/booting the app.Tests
test/lynx_web/endpoint_test.exscovers::http_max_body_lengthdefaults to8_000_000so existing deployments are unaffected.Plug.Parsers.init/1as:length.Test plan
mix test test/lynx_web/endpoint_test.exsis green.APP_HTTP_MAX_BODY_LENGTH=33554432and confirm a ~16 MB tfstate push succeeds.