Change ActionController::Parameters#require behavior when value is empty #9660

Merged
merged 1 commit into from Nov 2, 2013

Conversation

Projects
None yet
7 participants
Contributor

sebasoga commented Mar 11, 2013

When the value for the required key is empty an ActionController::ParameterMissing is raised which gets caught by ActionController::Base and turned into a 400 Bad Request reply with a message in the body saying the key is missing, which is misleading.

With these changes, ActionController::EmptyParameter will be raised which ActionController::Base will catch and turn into a 400 Bad Request reply with a message in the body saying the key value is empty.

Change ActionController::Parameters#require behavior when value is empty
When the value for the required key is empty an ActionController::ParameterMissing is raised which gets caught by ActionController::Base and turned into a 400 Bad Request reply with a message in the body saying the key is missing, which is misleading.

With these changes, ActionController::EmptyParameter will be raised which ActionController::Base will catch and turn into a 400 Bad Request reply with a message in the body saying the key value is empty.
Owner

guilleiguaran commented Mar 19, 2013

👍

/cc @spastorino @fxn

tomav commented Nov 1, 2013

Same problem here

Owner

rafaelfranca commented Nov 1, 2013

OMG! 8 months without review 😢

I'll try to get this into 4.0.2

guilleiguaran added a commit that referenced this pull request Nov 2, 2013

Merge pull request #9660 from sebasoga/change_strong_parameters_requi…
…re_behaviour

Change ActionController::Parameters#require behavior when value is empty

@guilleiguaran guilleiguaran merged commit c2b5a8e into rails:master Nov 2, 2013

Member

robin850 commented Nov 2, 2013

@guilleiguaran : this should be backported to 4-0-stable no ?

Wouldn't this need a changelog entry?

Owner

dhh commented Nov 2, 2013

I don't like this. We don't need two different exceptions, with two different things to catch if you're doing your own exception handling, to signify such a small change. Just expand the default message to be "Either key is missing or the value is empty".

Owner

guilleiguaran commented Nov 2, 2013

@dhh agree, I'll work now changing this.

guilleiguaran added a commit that referenced this pull request Nov 2, 2013

Revert "Merge pull request #9660 from sebasoga/change_strong_paramete…
…rs_require_behaviour"

This reverts commit c2b5a8e, reversing
changes made to 1918b12.

See: #9660 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment