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

ITC Team ID specified in AppFile isn't being passed to connect_api; now I get "Multiple Teams found; unable to choose" #17371

Closed
4 tasks done
ChristopherDrum opened this issue Oct 5, 2020 · 22 comments

Comments

@ChristopherDrum
Copy link

New Issue Checklist

Issue Description

#17153 says it fixed this issue, but to make a new report if we still have the problem.
I still have the problem.

Haven't had any troubles for weeks, but this showed up when trying to do an automated submission on September 25.
Not sure what version of Fastlane I was on at that particular time, but I do run an update each week before submission.
As of October 2, I was on Fastlane v.2.162.0 and still have the issue.

Command executed

Spaceship::ConnectAPI.login(<username>, <password>)
itc_team_id is defined in the AppFile, which was done explicitly to solve a "multiple team" issue in the past.

Complete output when running fastlane, including the stack trace and command used
/usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/rubygems/ext/builder.rb:165: warning: conflicting chdir during another chdir block
/usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/rubygems/ext/builder.rb:173: warning: conflicting chdir during another chdir block
/usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/portal/ui/select_team.rb:97:in `select_team': \e[31m[!] Multiple Teams found; unable to choose, terminal not interactive!\e[0m (RuntimeError)
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/portal/portal_client.rb:73:in `select_team'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/connect_api/client.rb:65:in `login'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/connect_api/spaceship.rb:82:in `login'
	from Fastfile:62:in `block in parsing_binding'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/lane.rb:33:in `call'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:352:in `run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/bin/fastlane:23:in `'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/bin/fastlane:23:in `load'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/bin/fastlane:23:in `'
/usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/portal/ui/select_team.rb:97:in `select_team': Multiple Teams found; unable to choose, terminal not interactive! (RuntimeError)
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/portal/portal_client.rb:73:in `select_team'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/connect_api/client.rb:65:in `login'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/connect_api/spaceship.rb:82:in `login'
	from Fastfile:62:in `block in parsing_binding'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/lane.rb:33:in `call'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:352:in `run'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/bin/fastlane:23:in `'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/bin/fastlane:23:in `load'
	from /usr/local/Cellar/fastlane/2.162.0/libexec/bin/fastlane:23:in `' 

Environment

✅ fastlane environment ✅

Stack

Key Value
OS 10.15.6
Ruby 2.7.1
Bundler? false
Git git version 2.27.0
Installation Source /usr/local/Cellar/fastlane/2.162.0/libexec/bin/fastlane
Host Mac OS X 10.15.6 (19G2021)
Ruby Lib Dir /usr/local/Cellar/ruby/2.7.1_2/lib
OpenSSL Version OpenSSL 1.1.1f 31 Mar 2020
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 11.5

System Locale

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

fastlane files:

`./Fastfile`
<redacted for private information; fastlane fails at the very first attempt to login with Spaceship in the first line of the lane definition (see above)>
`./Appfile`
apple_id "<redacted>"
itc_team_id "<redacted>"

fastlane gems

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

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.4.0
slack-notifier 2.3.2
atomos 0.1.3
CFPropertyList 3.0.2
claide 1.0.3
colored2 3.1.2
nanaimo 0.3.0
xcodeproj 1.18.0
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.6
addressable 2.7.0
multipart-post 2.0.0
word_wrap 1.0.0
tty-screen 0.8.1
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
excon 0.76.0
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.7
faraday_middleware 1.0.0
fastimage 2.2.0
gh_inspector 1.1.3
json 2.3.0
mini_magick 4.10.1
rubyzip 2.3.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
dotenv 2.7.6
bundler 2.1.2
naturally 2.2.0
simctl 1.6.8
jwt 2.2.2
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
multi_json 1.15.0
signet 0.14.0
memoist 0.16.2
os 1.1.1
googleauth 0.13.1
httpclient 2.8.3
google-api-client 0.38.0
google-cloud-env 1.3.3
google-cloud-errors 1.0.1
google-cloud-core 1.5.0
rake 13.0.1
digest-crc 0.6.1
google-cloud-storage 1.29.0
emoji_regex 3.0.0
jmespath 1.4.0
aws-partitions 1.379.0
aws-eventstream 1.1.0
aws-sigv4 1.2.2
aws-sdk-core 3.109.0
aws-sdk-kms 1.39.0
aws-sdk-s3 1.82.0
uri 0.10.0
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
ostruct 0.2.0
strscan 1.0.3
date 3.0.0
delegate 0.1.0
fileutils 1.4.1
io-console 0.5.6
zlib 1.1.0
singleton 0.1.0
mini_portile2 2.4.0
nokogiri 1.10.10
racc 1.4.16
rexml 3.2.3
open3 0.1.0
yaml 0.1.0
psych 3.1.0
mutex_m 0.1.0
webrick 1.6.0

generated on: 2020-10-04

@Katsz
Copy link
Contributor

Katsz commented Oct 5, 2020

I don't believe #17153 is somehow related. conflicting chdir during another chdir block sounds suspicious though. Can you double check you are running fastlane whatever in root directory of your project and there is ./fastlane folder inside?

@Katsz
Copy link
Contributor

Katsz commented Oct 5, 2020

You also may try to run something like

lane :temp do
    puts CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id)
end

If itc_team_id is present then something broke between 2.157.4 and 2.162.0.

@joshdholtz
Copy link
Member

Adding this to my queue to look into this week!

@joshdholtz joshdholtz self-assigned this Oct 5, 2020
@joshdholtz joshdholtz added this to Ready in Just Josh Things Oct 5, 2020
@ChristopherDrum
Copy link
Author

@Katsz Well, please remember that this was all working fine until two weeks ago, with no changes on my part.
Agreed about the chdir part, but that is in a file I don't control 🤷 I'm not sure what I'd do about that.
I'll try your CredentialsManager fetch trick and see what it turns up.

@ChristopherDrum
Copy link
Author

ChristopherDrum commented Oct 7, 2020

Running today, nokogiri seems to be one offender of the chdir issue 🤔

Fetching nokogiri-1.10.10.gem
Fetching mini_portile2-2.4.0.gem
Building native extensions. This could take a while...
/usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/rubygems/ext/builder.rb:165: warning: conflicting chdir during another chdir block
/usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/rubygems/ext/builder.rb:173: warning: conflicting chdir during another chdir block
[10:41:18]: Successfully installed 'nokogiri'

and I did track down one chdir issue in my Fastfile which I resolved, but did not improve this particular situation.

@Katsz CredentialsManager did properly return the value for itc_team_id, as set in the Appfile.
Expanding the temp lane...

lane :temp do
  puts CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id)
  Spaceship::ConnectAPI.login(<app store connect username>, <app store connect password>)
  app = Spaceship::ConnectAPI::App.find("<app store connect app id>")
  edit_version = app.get_edit_app_store_version(platform: Spaceship::ConnectAPI::Platform::IOS) 
end

quickly shows the problem for me. itc_team_id is properly printed to console, after which I'm immediately prompted to choose a team. However, it specifically says, "Multiple teams found on the Developer Portal". I thought developer portal was distinct from app store connect? Setting team_id in the Appfile doesn't work either.

So I switched my .login to the long-form
Spaceship::ConnectAPI.login(ENV['FASTLANE_USER'], ENV['FASTLANE_PASSWORD'], use_portal: false, use_tunes: true, portal_team_id: nil, tunes_team_id: ENV['itc_team_id'], team_name: nil, skip_select_team: true)
and this... works?... kind of?

I don't understand why explicitly specifying the itc_team_id in the .login function above results in this message:
The current user is in 2 teams. Pass a team ID or call select_team to choose a team. Using the first one for now.

@Katsz
Copy link
Contributor

Katsz commented Oct 15, 2020

I think it's related to ongoing migration from old whatever API to ConnectAPI...
I guess you are stuck with this long-form thing for the time being 🤷‍♂️

All in all I found naming of team id's, app id's and all sorts of other id's is kinda messy in fastlane.

@ChristopherDrum
Copy link
Author

@Katsz I only don't care for the long-form because the real message it says in fastlane is something like "multiple teams found, defaulting to the first one". That still sounds like it is not respecting my choice, but rather I'm just luckily defaulting to the account I want.

@hawkinsjb1
Copy link

I am also specifying team_id and itc_team_id in my Appfile and receiving:

Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.
Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.

Are there any temporary workarounds I can try until this is resolved?

@ChristopherDrum
Copy link
Author

@joshdholtz Any updates on this issue? You put it in your queue about 3 weeks ago; just curious to know if anything suspicious turned up yet?

@joshdholtz
Copy link
Member

Thanks for friendly ping! This should fall onto my Tuesday or Wednesday of this week! A few things from other fastlane related projects got interested in over the past few weeks along with some radar filing 🤷‍♂️ But nothing looks like it will be popping in this week so I should get to it soon ™️

@joshdholtz joshdholtz moved this from Ready to Doing in Just Josh Things Oct 26, 2020
@joshdholtz
Copy link
Member

joshdholtz commented Oct 27, 2020

@ChristopherDrum

Solving issue with workaround (#17371 (comment))

I think you need to try setting skip_select_team: false in your comment from above 👇 That will prevent the output of The current user is in 2 teams. Pass a team ID or call select_team to choose a team. Using the first one for now.

This defaults to false so that https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/connect_api/client.rb#L58-L70 gets executed which is needed to select the team(s) for the session.

Spaceship::ConnectAPI.login(ENV['FASTLANE_USER'], ENV['FASTLANE_PASSWORD'], 
  use_portal: false, 
  use_tunes: true, 
  portal_team_id: nil, 
  tunes_team_id: ENV['itc_team_id'], 
  team_name: nil, 
  skip_select_team: false # Make this false
)

Solving issue initially reported

The issue you initially reported looks like it was asking to select the portal team (and not the ITC/tunes team)...

/usr/local/Cellar/fastlane/2.162.0/libexec/gems/fastlane-2.162.0/spaceship/lib/spaceship/portal/ui/select_team.rb:97:in `select_team':

So it seems like what was happening was because both use_portal and use_tunes default to true and loading from your AppFile only specifies the ITC team it, it was still trying to login to portal - https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/connect_api/client.rb#L55-L56

Solution 1

The Spaceship::ConnectAPI module is combination of the developer portal and app store portal. This is because the official App Store Connect API (the one that uses the API Key) does not differentiate between the two. In order to make this appear the same for the Apple ID auth, the module needed to handle both developer portal team id and tunes/itc team id. It (by default) will want both. If you only have the itc team id and don’t want to use portal, you can just set use_portal: false

Spaceship::ConnectAPI.login(<username>, <password>, use_portal: false)

Solution 2

My preferred solution is that I always use team name instead of the id. The name is (usually) the same across both developer portal and tunes/itc so it can select the team from both. This might not work for everyone though

Set the team_name in your AppFile instead of itc_team_id.

Take Away

I’m going to update the docs to explain more of the parameters on this new login method so there is less confusion and also give some examples

@joshdholtz joshdholtz moved this from Doing to Maybe Handled in Just Josh Things Oct 27, 2020
@ChristopherDrum
Copy link
Author

@joshdholtz Thanks for the explanation. Given what you've said, it does seem that just a documentation update to clarify how/when these parameters are used and recommended best practices would be more than sufficient. I'll update my appfile and fastfile today.

@joshdholtz
Copy link
Member

@ChristopherDrum Sounds great! Let me know the result if you don't mind 😊 I'll update the docs once I hear back from you just to make sure that everything here is 💯

@joshdholtz
Copy link
Member

@ChristopherDrum Just checking in to see if everything is good for you now 😊

@ChristopherDrum
Copy link
Author

ChristopherDrum commented Nov 4, 2020

@joshdholtz Well, I made a rookie mistake last week and put team_name in my AppFile rather than itc_team_name (mixed up the Spaceship parameter name and the AppFile variable name) and had a failure. I should know today (I think) but I'm sure it will be fine.

@ChristopherDrum
Copy link
Author

@joshdholtz I'm sorry to say I'm having no success with this. Changing to your suggestion results in consist failures.

/usr/local/Cellar/fastlane/2.166.0/libexec/gems/fastlane-2.166.0/spaceship/lib/spaceship/tunes/tunes_client.rb:112:in `block in select_team': \e[31m[!] Multiple App Store Connect Teams found; unable to choose, terminal not interactive!\e[0m (RuntimeError)

I've set team_name and itc_team_name, individually and simultaneously. Every time I get this same error. Running fastlane's dsym uploader using team_name works perfectly earlier in the script. Trying some other tests this morning to see if there is a magical combination that works (specifically your "solution 1")

@joshdholtz
Copy link
Member

@ChristopherDrum That is weird! If you have some time this week I'd be happy to screenshare or something so we can debug what is going. I'd really love to figure out what is going on here 😊

@ChristopherDrum
Copy link
Author

@joshdholtz OK, exporting FASTLANE_ITC_TEAM_NAME worked. I don't mind doing this, but the Appfile is rendered useless. Again, this is fine but it definitely is handy to consolidate things in there, rather than shell scripts on my CI doing exports.

@joshdholtz
Copy link
Member

@ChristopherDrum Can you send me a sample of what your Fastfile looks like? I'm curious if something you are doing isn't triggering the AppFile to load 🤔

@ChristopherDrum
Copy link
Author

ChristopherDrum commented Nov 11, 2020

@joshdholtz Let me do an audit of sensitive info first. But, I can tell you that
puts CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name)
works fine (for example)

@fastlane-bot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest fastlane version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

Friendly reminder: contributions are always welcome! Check out CONTRIBUTING.md for more information on how to help with fastlane and feel free to tackle this issue yourself 💪

@fastlane-bot
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@fastlane fastlane locked and limited conversation to collaborators Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Just Josh Things
Maybe Handled
Development

No branches or pull requests

5 participants