Skip to content
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

Merged
merged 4 commits into from
Jul 19, 2022

Conversation

alishaevn
Copy link
Contributor

@alishaevn alishaevn commented Jul 18, 2022

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

expected behavior

  • account for when importerexporter.field_mapping is nil in the "get_field_mapping_hash_for" method

demo

image

@alishaevn alishaevn added patch-ver for release notes bug-fix labels Jul 18, 2022
instance_variable_set(
"@#{key}_hash",
mapping&.with_indifferent_access&.select { |_, h| h.key?(key) }
Copy link
Contributor Author

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 : {}
Copy link
Contributor Author

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.

@alishaevn alishaevn merged commit 1537577 into main Jul 19, 2022
@alishaevn alishaevn linked an issue Aug 5, 2022 that may be closed by this pull request
@alishaevn alishaevn deleted the undefined-method-length-for-nil-class branch December 1, 2022 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix patch-ver for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

split downloads by size
2 participants