-
Notifications
You must be signed in to change notification settings - Fork 23
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
undefined-method-length-for-nil-class #599
Conversation
…ield_mapping_hash_for
instance_variable_set( | ||
"@#{key}_hash", | ||
mapping&.with_indifferent_access&.select { |_, h| h.key?(key) } |
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.
because Bulkrax::Exporter.find(2).field_mapping
was returning nil
, line 81 returned nil
. this resulted in an error on line 83 because instance_variable_get("@#{key}_hash")
evaluated to nil
and nil.length
throws an error.
@@ -75,7 +75,7 @@ def related_children_parsed_mapping | |||
def get_field_mapping_hash_for(key) | |||
return instance_variable_get("@#{key}_hash") if instance_variable_get("@#{key}_hash").present? | |||
|
|||
mapping = importerexporter.field_mapping == [{}] ? {} : importerexporter.field_mapping | |||
mapping = importerexporter.field_mapping.is_a?(Hash) ? importerexporter.field_mapping : {} |
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.
either return the valid field mapping, or {} in all cases.
issue
ran into this issue while running this rake task on pals for all exporters that were exporting from a collection after updating to
v4.1.0
sentry error: https://sentry.notch8.com/sentry/pals/issues/142067/
![image](https://user-images.githubusercontent.com/29032869/179631860-7370fcf6-04df-4716-9e82-940a5fda86c7.png)
expected behavior
importerexporter.field_mapping
isnil
in the "get_field_mapping_hash_for" methoddemo