-
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
Deep symbolize keys when parsing options #312
Conversation
LGTM!! should we add a test here ? |
bb5bdca
to
b5f152a
Compare
Checked commit jntullo@b5f152a with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -10,7 +10,7 @@ def self.parse_user(data) | |||
|
|||
def self.parse_options(data) | |||
raise BadRequestError, "Request is missing options" if data["options"].blank? | |||
data["options"].symbolize_keys | |||
data["options"].deep_symbolize_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can API save the data in the same format as what UI does? Currently the data saved via UI is like this.
---
:src_ids:
- '7000000000029'
:vm_memory: 1024
:disk_add:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
disk_size_in_mb: '1'
persistent: true
thin_provisioned: true
new_controller_type: VirtualLsiLogicController
dependent: true
bootable: false
:request_type: :vm_reconfigure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lfu we could possibly convert to yaml...however, at the moment it is not playing nice:
TypeError: no implicit conversion of Symbol into Integer
from /Users/jilliantullo/code/manageiq/app/models/mixins/miq_request_mixin.rb:4:in `[]'
After looking at it, it appears that the create_request
method we are calling is expecting a hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jntullo options
is a serialized column. So DB saves the options
data in yaml format. I was hoping to keep the data format in DB the same as what UI does. Hash
would work if the format can't be exactly the same. Currently all the callers use the options key as a symbol.
Thanks @jntullo for fixing this 👍 |
@simaishi This is marked fine/yes, but @imtayadeway has opened ManageIQ/manageiq#17300 for backport. |
@imtayadeway Is there a BZ associated with this PR? |
@imtayadeway closed ManageIQ/manageiq#17300 because I think you can just backport even though it's a split repo. If you need/want it reopened, feel free. |
@miq-bot remove-label bugzilla needed |
Fine backport details:
|
Deep symbolize keys when parsing options (cherry picked from commit 4e7edaa) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1623573
Gaprindashvili backport details:
|
When parsing the options for creating / updating a request, only
:symbolize_keys
is being called. However, all of the keys must be symbolized via:deep_symbolize_keys
Related: ManageIQ/manageiq#16891
Fixes #260
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1618517
cc: @lfu @evertmulder