-
Notifications
You must be signed in to change notification settings - Fork 141
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
Blacklist Config Values #135
Blacklist Config Values #135
Conversation
@jntullo I don't think this is a good solution. As mentioned in the issue, this is not about 2 methods. This is about every method defined on Object, OpenStruct or Config::Options. Right now, we're hitting problems with 2 of them but that's not really future-proof. (I'm almost sure if we ever add a gem that extends Object to add a method named after anything already in the config, it will break the API equally well.) Can we use a whitelist instead? (But IMO the only fix that would really fix the issue is replace Config::Options with something that doesn't do |
I think this is a great solution - when replacing the |
@chrisarcand I don't know how much it's being used and what all is used from it, but.. would it really be that hard to replace? But.. assuming the gem can't be replaced, I'm good with this. I still think we'll hit these problems again, but .. eh, maybe not soon. |
I agree with @himdel as this is not API's concern to blacklist the config gem. If anything, it belongs in Vmdb::Settings. See my comment in the issue : #134 (comment) |
I think a better solution to this is: don't do that. Having a blacklist elsewhere to ensure we don't add conflicting keys to the config I'm all for. The problem in this case was that we were looking for settings that weren't there, and that's the part I'm suggesting we tackle. |
I don't disagree but this is not API's concern...it's a general concern, and can happen to anyone that tries to access the config. Even so (and I commented in the other thread with this), if all that's trying to be done is verify the presence of a key, then you can also use Settings.sdkfjhsdkfjh
# => nil
Settings.display
# OMGSOMUCHOUTPUT=>nil
Settings.to_h.include?(:sdkfjhsdkfjh)
# => false
Settings.to_h.include?(:display)
# => false
# And for fun ;)
Settings.sdkfjhsdkfjh = 123
Settings.to_h.include?(:sdkfjhsdkfjh)
=> true |
Checked commits jntullo/manageiq-api@fa8e1ef~...00d91a7 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
Thanks @jntullo for fixing this. 👍 |
…alues Blacklist Config Values
Neat! Could you rename the PR (and maybe edit description) to reflect the final solution? |
Proposed solution to resolve #134
Rather than rescuing an error, blacklist the
:system
and:display
values. Not allowing the:display
value to be called will resolve issues with the config being displayed in the console output, and removing the call to:system
removes the need for the rescue block.cc: @himdel @chrisarcand
@miq-bot add_label bug
@miq-bot assign @abellotti