-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 accessing first element of nil array in upload_price_tier #21213
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Any chance this MR can get into a release soon? We are unable to distribute apps on |
@@ -21,7 +21,7 @@ def upload(options) | |||
# Need to get prices from the app's relationships | |||
# Prices from app's relationship doess not have price tier so need to fetch app price with price tier relationship | |||
app_prices = app.prices | |||
if app_prices.first | |||
if app_prices && app_prices.first |
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.
This can be shortened to the following:
if app_prices && app_prices.first | |
if app_prices&.first |
However, I don't think it is the correct fix. It seems app.prices
is nil
even on already released app, so you would end up always going in the else
branch of this if
, even if App Store Connect does have prices.
As mentioned in #21187, proper support for the new prices API is needed.
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.
I agree, this fix is not a proper way of handling broken upload_price_tier. Also, the workaround in #21199 works well enough.
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 validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
Resolves #21199
Description
Error "undefined method `first' for nil:NilClass" indicates attempting to treat nil as an array. Adding pre-condition to check if the array is not nil fixes that. Also the startDate attribute of the resource appPrices in spaceship does not exist anymore and must be removed.
Testing Steps
Calling the deliver action for apps with unspecified prices now works as expected.