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

Stop replacing Plug Conn params and body_params #376

Conversation

lucacorti
Copy link
Contributor

@lucacorti lucacorti commented Jul 24, 2021

Hi,

Currently Plug.Conn params and body_params are replaced when casting via OpenApiSpex.Plug.CastAndValidate.
This creates issues with dialyzer (#92) and apparently breaks Plug.Upload (#370) too.

Unfortunately this can't be addressed in a backwards compatible way, so what I'm proposing in this PR is:

  • Add casted_body_params and casted_params to conn assigns with the casted version
  • Add config flags to disable the old behaviour of modifying Plug.Conn params and body_params.
  • Add compilation warnings if the config flag is not set (default) to warn about the breaking change in the next major

This way this change could be immediately merged, and people can start migrating today if they need to.

@lucacorti lucacorti marked this pull request as draft July 24, 2021 18:48
@lucacorti lucacorti force-pushed the feature/move-params-to-conn-assigns branch from 70f0450 to cb1b058 Compare July 24, 2021 18:52
@lucacorti lucacorti marked this pull request as ready for review July 24, 2021 19:11
@lucacorti
Copy link
Contributor Author

Not sure what is happening on 1.9.

@lucacorti
Copy link
Contributor Author

Elixir 1.9 is not compatible with OTP 23, so I excluded it from the current test matrix.

https://hexdocs.pm/elixir/1.12/compatibility-and-deprecations.html

@zoten
Copy link
Contributor

zoten commented Jan 10, 2022

Hi everyone! Any chance for this or 398 to enter the main tree?
Are there any blockers? Thanks!

@mbuhot
Copy link
Collaborator

mbuhot commented Jan 11, 2022

@zoten both this PR and #398 use a global application environment flag to toggle the behaviour.
I'd prefer to use a flag passed to the CastAndValidate plug (or perhaps a new plug altogether), allowing controllers to be updated one at a time.

@mbuhot
Copy link
Collaborator

mbuhot commented May 15, 2022

Closing in favour of #425

@mbuhot mbuhot closed this May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants