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
Fix crash in match when passing a frozen value as app_identifiers #20125
Fix crash in match when passing a frozen value as app_identifiers #20125
Conversation
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.
Ya, ooops 🤦♂️
I test private methods in languages that make it easy to do if the effort is low and potential impact of a bug is high. In this case, I'd say... nahhh.
🎈🐐
Hey @AliSoftware 👋 Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉 Please let us know if this change requires an immediate release by adding a comment here 👍 |
❤️ y'all |
(°◡°♡) .:。 |
Congratulations! 🎉 This was released as part of fastlane 2.205.2 🚀 |
As the PR fixing the issue has now landed in fastlane 2.205.2 See fastlane/fastlane#20125
As the PR fixing the issue has now landed in fastlane 2.205.2 See fastlane/fastlane#20125
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validI've updated the documentation if necessary.Motivation and Context
When calling
match
with a frozen array (our_app_ids.freeze
) for theapp_identifiers
parameter, we got a crash becausematch
is trying to mutate that input value in-place. See wordpress-mobile/WordPress-iOS@cd585ae for some more details.This PR replaces the mutation in-place with a new assignment instead, to avoid modifying the original value that the call site passed to
match
.Description
This crash was due to this patching PR (made back in 2017 by @taquitos to quick-fix another issue), which calls
app_identifiers.flatten!
, mutating that parameter in place.app_identifiers = app_identifiers.flatten
, to avoid modifying the original in-place and thus allow frozen values to be passed at call site.FastlaneCore::ConfigItem#auto_convert_value
to already take care of this nowadays, right?auto_convert_value
appeared after the patch from 2017 (meaning that thatauto_convert_value
of comma-separated strings to Array did not exist back then and was added later, rendering this.split(/\s*,\s*/).uniq
inmatch
now obsolete) or was already present back then (meaning that the bug in match that we tried to patch was due to something else and more complicated)… 🤔Testing Steps
I thought about writing a spec for this but couldn't think of a reliable way of how to test just this part of the
Match::Runner
without stubbing basically everything, only to test that line in isolation.Another option could have been to extract lines L79-L87 into a dedicated private method, and write a test for it. But:
ConfigItem#auto_convert_value
should already cover all this nowadays) first(\cc @mokagio FYI, as the discoverer of that bug in our tooling)