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

ActionController::UnpermittedParameters: found unpermitted parameters: #47

Open
kevincraig opened this issue Jun 16, 2021 · 8 comments
Open

Comments

@kevincraig
Copy link

I am getting the error ActionController::UnpermittedParameters: found unpermitted parameters: when doing a post to our API.

Currently, I have Application.rb setup as follows:
config.middleware.use OliveBranch::Middleware, inflection: 'camel', content_type_check: -> (content_type) { true }

All of my GET requests work fine, so far every POST is failing with the error except my login endpoint, I'm digging through that to see if I can find a difference that would cause this issue.

This is from the logs on the request so I can see that it is converting it to snake case. I have this happening on multiple controllers.
:params => { "appointment" => { "address_id" => "22", "start_at" => "2021-06-18T17:30:00", "origin" => "paw", "appointment_vehicles_attributes" => [ { "package_id" => "18", "upgrade_ids" => [ "2", "3" ], "vehicle_id" => "1" } ] } },

@dce
Copy link
Member

dce commented Jun 16, 2021

Hey @kevincraig what do you have set up for your permitted parameters for that request?

@kevincraig
Copy link
Author

@dce Here is the params list, currently just require it to be 'appointment' hopefully I didn't misspell something. ha..

json_params.require(:appointment).permit(:id, :aasm_state, :upcharge_reason, :tax_amount, :tax_rate, :tax_description, :travel_fee, :travel_fee_description, :start_at, :origin,
:address_id, :promo_code, :promo_code_value, :promo_code_description, :promo_code_text, :via_partner_code, :promo_amount, :package_ids => [], :upgrade_ids => [], appointment_vehicles_attributes: [:id, :review_rating, :review_comments, :package_id,
:vehicle_id, :interior_condition, :interior_condition_notes,
:exterior_condition, :exterior_condition_notes, :upgrade_ids => []])

@dce
Copy link
Member

dce commented Jun 17, 2021

Hmm, look OK to me. Does it give any more info after "found unpermitted parameters" (like what the params are)?

@kevincraig
Copy link
Author

found unpermitted parameters: addressId, startAt, appointmentVehiclesAttributes
Some additional information, this instance of the API is running on Docker and we are currently on Rails 4.2(I know). We're moving to 5.2 soon.

@dce
Copy link
Member

dce commented Jun 18, 2021

Hey @kevincraig nothing's jumping out at me -- possible that json_params method is doing something funny?

@kevincraig
Copy link
Author

@dce No problem. I'll poke around some more on my end. I'm also going to pull down our 5.2 Branch and give it a try as well. I'll update the issue either way.

@kevincraig
Copy link
Author

Just a quick update, I migrated my branch to Rails 5.0 and I still see the same error, I have one other POST endpoint that is working but it has params.require(:class).permit!. I changed that on the other controller and I am now getting other errors but that's not idea to have to use permit!.

@kevincraig
Copy link
Author

@dce well I figured out what the issue is, just not exactly sure how to go about fixing it. It looks like anytime I have an endpoint with params that are 2 words or more the post fails. For example, when creating a vehicle object I have year, make, model, subModel, vehicleTypeId. When I try and post that I get the error. Now if I take that exact call and change subModel => sub_model and vehicleTypeId => vehicle_type_id everything works fine. I know the gem is working from a GET aspect as all my requests come back in camel case. I'm at a loss right now but will keep digging.

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

No branches or pull requests

2 participants