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

[fastlane_core] symbolize keys in options of type Hash #19424

Merged
merged 4 commits into from
Oct 13, 2021

Conversation

keeshux
Copy link
Contributor

@keeshux keeshux commented Oct 2, 2021

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 Hash options are provided via environment, they are parsed as JSON and auto-converted to a hash. However, Ruby treats string and symbol keys differently, and fastlane actions normally expect keys as symbols.

Description

Converts keys to symbols when parsing an option from a JSON string in the environment.

Testing Steps

The APP_STORE_CONNECT_API_KEY environment variable is a common example exposing the issue. Any key inside the JSON would be parsed as nil, because accessing e.g. "key_id" (parsed) is different than :key_id (expected).

When Hash options are provided via environment, they are parsed as
JSON and auto-converted to a hash. However, Ruby treats string and
symbol keys differently, and fastlane actions normally expect keys
as symbols.
@google-cla google-cla bot added the cla: yes label Oct 2, 2021
@joshdholtz joshdholtz changed the title Symbolize keys in options of type Hash [fastlane_core] symbolize keys in options of type Hash Oct 11, 2021
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this theory! But it looks like this breaks some existing tests 😔 I think the correct solution for the issue here might be to fix the string/symbol lookup in the App Store Connect API Key area if that is where its happening 🤷‍♂️ Thoughts?!

Parse JSON properly when fetched from environment variable.
@keeshux
Copy link
Contributor Author

keeshux commented Oct 11, 2021

I like this theory! But it looks like this breaks some existing tests 😔 I think the correct solution for the issue here might be to fix the string/symbol lookup in the App Store Connect API Key area if that is where its happening 🤷‍♂️ Thoughts?!

Yeah! I saw that l10n tests failed in CI, probably for the opposite reason. In fact such a change might have subtle and undesired consequences.

Therefore, I reverted the global change and restricted the fix to the app_store_connect_api_key action, which is where the bug is most apparent to my experience.

@keeshux keeshux requested a review from joshdholtz October 11, 2021 20:39
@google-cla
Copy link

google-cla bot commented Oct 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Oct 13, 2021
@joshdholtz
Copy link
Member

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Oct 13, 2021
@keeshux
Copy link
Contributor Author

keeshux commented Oct 13, 2021

@googlebot I consent.

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you so much for fixing this 🥰

@joshdholtz joshdholtz merged commit ac88987 into fastlane:master Oct 13, 2021
Copy link

@fastlane-bot fastlane-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@fastlane fastlane locked and limited conversation to collaborators Dec 14, 2021
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.

3 participants