fastlane: NoMethodError: [!] undefined method `status' for nil:NilClass

New Issue Checklist

Issue Description

While upload to AppStore with created .ipa file in previous steps I’m getting error NoMethodError: [!] undefined method `status' for nil:NilClass

Command executed
    upload_to_app_store(
      ipa: ipa_path_release,
      skip_binary_upload: false,
      skip_metadata: true,
      skip_screenshots: true,
      app_identifier: bundle_id,
      force: true,
      app_version: version,
      username: username,
      team_id: connect_team,
      dev_portal_team_id: dev_team
    )
Complete output when running fastlane, including the stack trace and command used
 ```
bundler: failed to load command: fastlane (/usr/local/bin/fastlane)
NoMethodError: [!] undefined method `status' for nil:NilClass
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/spaceship/lib/spaceship/connect_api/client.rb:151:in `handle_response'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/spaceship/lib/spaceship/connect_api/client.rb:110:in `patch'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/spaceship/lib/spaceship/connect_api/tunes/tunes.rb:742:in `patch_app_store_version'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/spaceship/lib/spaceship/connect_api/models/app_store_version.rb:90:in `update'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/spaceship/lib/spaceship/connect_api/models/app.rb:171:in `ensure_version!'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/deliver/lib/deliver/runner.rb:97:in `verify_version'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/deliver/lib/deliver/runner.rb:36:in `run'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/actions/upload_to_app_store.rb:17:in `run'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/actions/actions_helper.rb:50:in `execute_action'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:229:in `chdir'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
  Fastfile:98:in `upload_result_to_appstore'
  Fastfile:51:in `block (2 levels) in parsing_binding'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/lane.rb:33:in `call'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:45:in `chdir'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/runner.rb:45:in `execute'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
  /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
  /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
  /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
  /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/commands_generator.rb:352:in `run'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
  /Library/Ruby/Gems/2.6.0/gems/fastlane-2.156.1/bin/fastlane:23:in `<top (required)>'
  /usr/local/bin/fastlane:23:in `load'
  /usr/local/bin/fastlane:23:in `<top (required)>'
``` 

Environment

 
✅ fastlane environment ✅

Stack

Key Value
OS 10.15.6
Ruby 2.6.3
Bundler? false
Git git version 2.24.3 (Apple Git-128)
Installation Source /usr/local/bin/fastlane
Host Mac OS X 10.15.6 (19G73)
Ruby Lib Dir /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
OpenSSL Version LibreSSL 2.8.3
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 11.6

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
default_platform(:ios)

platform :ios do

  before_all do
    sh("rm -rf #{derived_data_path}")
  end

  lane :upload do |options|
    branchName = options[:branch]
    targetName = options[:target]
    buildNumber = options[:build]
    version = options[:version]
    
    $params = apps[targetName]
    $build_number = buildNumber != nil ? buildNumber : get_build_number
    $version_string = version != nil ? version : product_version_number

    update_version_and_build
    sh("git checkout #{branchName}") if branchName != nil
    product_create_archive
    make_ipa_for_appstore
    upload_result_to_appstore(false)
  end

end

`./fastlane/Appfile`

# For more information about the Appfile, see:
#     https://docs.fastlane.tools/advanced/#appfile

fastlane gems

Gem Version Update-Status
fastlane 2.156.1 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.3.0
slack-notifier 2.3.2
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
unicode-display_width 1.7.0
terminal-table 1.8.0
plist 3.5.0
public_suffix 4.0.5
addressable 2.7.0
multipart-post 2.0.0
word_wrap 1.0.0
tty-cursor 0.7.1
tty-spinner 0.9.3
babosa 1.0.3
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
faraday 1.0.1
unf_ext 0.0.7.7
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.3
faraday-cookie_jar 0.0.6
faraday_middleware 1.0.0
gh_inspector 1.1.3
mini_magick 4.10.1
rubyzip 2.3.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
bundler 1.17.2
naturally 2.2.0
simctl 1.6.8
uber 0.1.0
declarative 0.0.20
declarative-option 0.1.0
representable 3.0.4
retriable 3.1.2
mini_mime 1.0.2
signet 0.14.0
httpclient 2.8.3
google-api-client 0.38.0
emoji_regex 3.0.0
nanaimo 0.3.0
colored2 3.1.2
claide 1.0.3
CFPropertyList 3.0.2
atomos 0.1.3
xcodeproj 1.18.0
tty-screen 0.8.1
excon 0.76.0
fastimage 2.2.0
json 2.3.1
dotenv 2.7.6
jwt 2.2.1
multi_json 1.15.0
os 1.1.1
memoist 0.16.2
googleauth 0.13.1
rake 13.0.1
digest-crc 0.6.1
google-cloud-errors 1.0.1
google-cloud-env 1.3.3
google-cloud-core 1.5.0
google-cloud-storage 1.27.0
aws-eventstream 1.1.0
aws-sigv4 1.2.2
aws-partitions 1.356.0
jmespath 1.4.0
aws-sdk-core 3.104.3
aws-sdk-kms 1.36.0
aws-sdk-s3 1.78.0
forwardable 1.2.0
logger 1.3.0
stringio 0.0.2
ipaddr 1.2.2
openssl 2.1.2
ostruct 0.1.0
strscan 1.0.0
date 2.0.0
fileutils 1.1.0
etc 1.0.1
io-console 0.4.7
zlib 1.0.0
libxml-ruby 3.1.0
rexml 3.1.9
psych 3.1.0
mutex_m 0.1.0
webrick 1.4.2

generated on: 2020-08-18

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 29 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I think I’ve found the root problems here, from I think there are 2:

  1. The error is thrown when you do a step which your API key is not entitled to (for example, in our case, we use a Developer scope key, but fastlane pilot tries to update the beta app review info). The patch_beta_app_review_detail call results in a 403 Forbidden status code, but this is not handled correctly by fastlane :
{
	"errors": [{
		"id": "fb848346-8dfa-48e8-b99b-8a87bf30b329",
		"status": "403",
		"code": "FORBIDDEN_ERROR",
		"title": "This request is forbidden for security reasons",
		"detail": "The API key in use does not allow this request"
	}]
}
  1. The other problem I see here is that why pilot calls patch_beta_app_review_detail, when we did not set this anywhere in the lanes? What I see is, that the demoAccountRequired field is set regardless of the setup, and this causes the unwanted call in point 1. As I’ve found, the options[:demo_account_required] is a required option, and as such it won’t be null, so every pilot call will update the beta app review info: `https://github.com/fastlane/fastlane/blob/addb520b0f2405fdb917ea479c3a2f4a12a01b8b/pilot/lib/pilot/build_manager.rb#L217

So, you can workaround point 1. by using a key with higher level permission. (But I think handling this response should be fixed in https://github.com/fastlane/fastlane/blob/addb520b0f2405fdb917ea479c3a2f4a12a01b8b/spaceship/lib/spaceship/connect_api/api_client.rb#L176)