fastlane: "NoMethodError: [!] undefined method `status' for nil:NilClass" error received when using upload_to_testflight(api_key: api_key) action

cc: @joshdholtz

New Issue Checklist

Issue Description

I’m trying to use the new App Store Connect API integration with Fastlane. I am doing this by using the following action:

api_key = app_store_connect_api_key
upload_to_testflight(api_key: api_key)

I am taking advantage of this action being able to automatically read from the ENV variables I have defined in CircleCI. The ENV variables I am using are:

  1. APP_STORE_CONNECT_API_KEY_IN_HOUSE
  2. APP_STORE_CONNECT_API_KEY_ISSUER_ID
  3. APP_STORE_CONNECT_API_KEY_KEY
  4. APP_STORE_CONNECT_API_KEY_KEY_ID

It was confusing to me what duration and in_house mean, so I decided to omit duration, and am passing false for in_house.

It also should be noted that I found it confusing as to how to format the P8 Key in a single string since the P8 has multiple line breaks including line breaks that break up parts of the actual content of the key. However from the examples in the docs it seems to only show adding line breaks before and after the content of the key.

I am formatting my APP_STORE_CONNECT_API_KEY_KEY as follows: -----BEGIN PRIVATE KEY-----\nthiswherethekeywouldbe\n-----END PRIVATE KEY-----

For example if the P8 was (not my actual p8, just typed random characters):

-----BEGIN PRIVATE KEY----
LKJSBLK384723O8FB4378B
3C48BF3487B3788BF34F43
348BF743F78B34OF83B4FO
-----END PRIVATE KEY-----

I then formatted my APP_STORE_CONNECT_API_KEY_KEY to: -----BEGIN PRIVATE KEY-----\nLKJSBLK384723O8FB4378B3C48BF3487B3788BF34F43348BF743F78B34OF83B4FO\n-----END PRIVATE KEY-----

Command executed
api_key = app_store_connect_api_key
upload_to_testflight(api_key: api_key)
Complete output when running fastlane, including the stack trace and command used
 +------+--------------------------------------+-------------+
|                     fastlane summary                      |
+------+--------------------------------------+-------------+
| Step | Action                               | Time (in s) |
+------+--------------------------------------+-------------+
| 1    | Verifying fastlane version           | 0           |
| 2    | import_from_git                      | 0           |
| 3    | default_platform                     | 0           |
| 4    | is_ci                                | 0           |
| 5    | setup_circle_ci                      | 0           |
| 6    | automatic_code_signing               | 0           |
| 7    | match                                | 2           |
| 8    | Switch to ios bump_build_number lane | 0           |
| 9    | buildnumber_xyz                      | 0           |
| 10   | increment_build_number               | 3           |
| 11   | add_badge                            | 2           |
| 12   | gym                                  | 212         |
| 13   | app_store_connect_api_key            | 0           |
| 💥   | upload_to_testflight                 | 3           |
+------+--------------------------------------+-------------+

[21:10:32]: fastlane finished with errors

Looking for related GitHub issues on fastlane/fastlane…

➡️ [!] undefined method `any?’ for nil:NilClass (NoMethodError) https://github.com/fastlane/fastlane/issues/17048 [open] 14 💬 2 weeks ago

➡️ undefined method `get_app_info_localizations’ for nil https://github.com/fastlane/fastlane/issues/17208 [open] 4 💬 5 days ago

➡️ [supply] undefined method `map’ for nil:NilClass on “draft” tracks https://github.com/fastlane/fastlane/issues/17086 [open] 2 💬 2 days ago

and 277 more at: https://github.com/fastlane/fastlane/search?q=undefined method `status' for nil&type=Issues&utf8=✓

🔗 You can ⌘ + double-click on links to open them directly in your browser. bundler: failed to load command: fastlane (/Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane) NoMethodError: [!] undefined method status' for nil:NilClass /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/spaceship/lib/spaceship/connect_api/api_client.rb:176:in handle_response’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/spaceship/lib/spaceship/connect_api/api_client.rb:113:in get' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/spaceship/lib/spaceship/connect_api/testflight/testflight.rb:22:in get_apps’ /Users/distiller/.rubies/ruby-2.7.1/lib/ruby/2.7.0/forwardable.rb:235:in get_apps' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/spaceship/lib/spaceship/connect_api/models/app.rb:56:in all’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/spaceship/lib/spaceship/connect_api/models/app.rb:61:in find' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/pilot/lib/pilot/manager.rb:61:in fetch_app_id’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/pilot/lib/pilot/build_manager.rb:23:in upload' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/actions/upload_to_testflight.rb:27:in run’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:263:in block (2 levels) in execute_action' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in execute_action’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:255:in block in execute_action' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:229:in chdir’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:229:in execute_action' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:157:in trigger_action_by_name’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/fast_file.rb:159:in method_missing' Fastfile:51:in block (2 levels) in parsing_binding’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/lane.rb:33:in call' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:49:in block in execute’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:45:in chdir' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/runner.rb:45:in execute’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/lane_manager.rb:47:in cruise_lane' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/command_line_handler.rb:36:in handle’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/commands_generator.rb:108:in block (2 levels) in run' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in call’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in run' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in run_active_command’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in run!' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in run!’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/commands_generator.rb:352:in run' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/commands_generator.rb:41:in start’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in take_off' /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.161.0/bin/fastlane:23:in <top (required)>’ /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in load' /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in <top (required)>’

Exited with code exit status 1 CircleCI received exit code 1

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 12.0

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL
LANGUAGE

fastlane gems

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

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-badge 1.4.0 ✅ Up-To-Date
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
terminal-table 1.8.0
plist 3.5.0
addressable 2.7.0
multipart-post 2.0.0
word_wrap 1.0.0
babosa 1.0.3
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
faraday 1.0.1
faraday_middleware 1.0.0
gh_inspector 1.1.3
rubyzip 2.3.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
uber 0.1.0
declarative-option 0.1.0
representable 3.0.4
retriable 3.1.2
mini_mime 1.0.2
httpclient 2.8.3
google-api-client 0.38.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
unicode-display_width 1.7.0
public_suffix 4.0.6
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
excon 0.76.0
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.7
fastimage 2.2.0
json 2.3.1
mini_magick 4.10.1
dotenv 2.7.6
bundler 2.1.4
naturally 2.2.0
simctl 1.6.8
jwt 2.2.2
declarative 0.0.20
multi_json 1.15.0
signet 0.14.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.29.0
emoji_regex 3.0.0
aws-eventstream 1.1.0
aws-sigv4 1.2.2
aws-partitions 1.376.0
jmespath 1.4.0
aws-sdk-core 3.108.0
aws-sdk-kms 1.38.0
aws-sdk-s3 1.81.1
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
curb 0.9.10
badge 0.12.0
fastlane-plugin-badge 1.4.0

generated on: 2020-09-28

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 27 (15 by maintainers)

Most upvoted comments

BTW… I’m thinking of adding a Base64 option of some sort onto key_content so that you don’t need to deal with weird new lines and stuff 🤷‍♂️

Hello! Working on a solution for this today 😊 Got side tracked by some other emergency issues that came up 😬

@joshdholtz yes, it looks like it works for me. Thanks! This is my Gemfile:

gem ‘fastlane’, git: “https://github.com/fastlane/fastlane”, ref: “48151291f2c4949c3b1b9919ba2cc81a7cc33293”

I’m also receiving this error uploading to testflight. Weirdly, the lane Successfully finished processing and also appears in AppStoreConnect, but the lane crashes eventually with the same error.

@xanderbuck I think I’m going to keep this open and see if we can provide some more useful feedback when the P8 is bad 😊 I’m sure there will be more reports of this if we don’t… which is totally fair 😉

And welcome to community! So happy to have you 😊 Glad you had a good experience! Hopefully we see (and don’t see you) more 😝