Hashie warning "You are setting a key that conflicts with a built-in method"
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
Hashie 3.5.5
Grape 0.19.2
To reproduce:
require "grape"
class MyAPI < Grape::API
params do
requires :update, type: Boolean
end
get "hoge" do
"update = #{params[:update]}"
end
end
run MyAPI
Log:
W, [2017-06-06T14:18:35.531821 #46633] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#update defined at /Users/val00362/tmp/grapetest/vendor/bundle/ruby/2.3.0/gems/hashie-3.5.5/lib/hashie/mash.rb:209. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Hashie::Mash has built-in update method. It's conflicting with my parameter name. Similarly, you would see the warning when you used any of Hashie::Mash's 280+ methods. Is there any workaround about this? Or at least, some caveat to avoid these parameter names should be written in the README.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied Grape API example with the reported Hashie 3.5.5 and Ruby versions to reproduce the warning. Inspect Hashie::Mash and the referenced hashie/mash.rb location, then review the README for guidance on conflicting parameter names. Done means providing a verified workaround or documenting the relevant caveat.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100