-
Notifications
You must be signed in to change notification settings - Fork 548
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
Check for @values in StripeObject#method_not_found #122
Conversation
If a StripeObject is being deserialized by psych, @values.has_key? is called before @values is initialized which prevents proper deserialization from occurring. Checking for existence first resolves the issue.
👍 This works for me. When is this pull request likely to be merged? |
+1 hitting this as well. |
+1 happening to me as well |
fwiw, I got around this in rails by switching from yaml to json store. eg. serialize :charge_response, JSON |
+1, getting this too. |
Same here. 👍 |
+1 got this as well |
Hi all, sorry for the absurdly late response here. Huh, that's weird. I wonder if there's something buggy happening upstream that we'll just be covering up by adding the nil check -- will investigate. |
Ok, after digging into this it looks like this is because Not really sure there's a way to get around this, and Psych fills in all of the instance variables that would otherwise be set by 0: https://github.com/tenderlove/psych/blob/master/lib/psych/visitors/to_ruby.rb#L339 |
Check for `@values` in StripeObject#method_not_found. This is necessary because we check for `@values` in `respond_to_missing?` now, but this isn't necessarily always set. For example, in deserializing from YAML, Psych creates the object using `allocate` and not `new`, which ends up skipping any initializing of instance variables. See #122 for more details.
Previous to 1.10.0 StripeObjects could be deserialized from YAML without issue. I believe #99 introduced an issue where
@values.has_key?
is called before@values
is initialized which prevents proper deserialization from occurring.This is the backtrace, I got and I've verified this change resolves the issue: