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

Fix crash in match when passing a frozen value as app_identifiers #20125

Merged
merged 1 commit into from Mar 25, 2022

Conversation

AliSoftware
Copy link
Contributor

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

When calling match with a frozen array (our_app_ids.freeze) for the app_identifiers parameter, we got a crash because match 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.

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:

  • I'm not sure how the fastlane team regards "testing private methods" (quite a controversial topic)
  • I preferred to gather feedback on the fix implementation (i.e. will this patch do for now, or do we consider we can get rid of all the L79-L87 logic and consider that ConfigItem#auto_convert_value should already cover all this nowadays) first

(\cc @mokagio FYI, as the discoverer of that bug in our tooling)

Copy link
Collaborator

@taquitos taquitos left a 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.

🎈🐐

@taquitos taquitos merged commit acb7d84 into fastlane:master Mar 25, 2022
@AliSoftware AliSoftware deleted the match/fix-flatten-mutating branch March 25, 2022 21:40
@fastlane-bot
Copy link

Hey @AliSoftware 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@mokagio
Copy link
Contributor

mokagio commented Mar 29, 2022

❤️ y'all

@taquitos
Copy link
Collaborator

❤️ y'all

(°◡°♡) .:。

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.205.2 🚀

AliSoftware added a commit to wordpress-mobile/WordPress-iOS that referenced this pull request Apr 21, 2022
As the PR fixing the issue has now landed in fastlane 2.205.2

See fastlane/fastlane#20125
AliSoftware added a commit to woocommerce/woocommerce-ios that referenced this pull request Apr 21, 2022
As the PR fixing the issue has now landed in fastlane 2.205.2

See fastlane/fastlane#20125
@fastlane fastlane locked and limited conversation to collaborators Jun 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants