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 accessing first element of nil array in upload_price_tier #21213

Closed
wants to merge 2 commits into from

Conversation

lanpau
Copy link

@lanpau lanpau commented Apr 18, 2023

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 see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

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.

@google-cla
Copy link

google-cla bot commented Apr 18, 2023

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.

@markmuniz
Copy link

Any chance this MR can get into a release soon? We are unable to distribute apps on 2.212.2 due to this issue. Downgrading to 2.212.1 is our only workaround for now.

@@ -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
Copy link
Contributor

@vincentisambart vincentisambart May 7, 2023

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:

Suggested change
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.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fastlane getting "The request could not be completed because: Server error got 500" error for iOS Apps
4 participants