It can happen that the phone number returned by Apple contains NBSP characters. When it does, the step of selecting the phone number automatically from the SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER env var fails with this message:
[!] The request could not be completed because:
Could not find a matching phone number to ...
This issue is very weird, we have several different Apple accounts, most of which don't have this issue. This problem only happens on a single specific Apple account, and it doesn't even happen consistently.
When I got stuck with the problem on my machine, I did some debugging by modifying my Fastlane installation files manually and found the source of the problem like this.
This is the output of printing the phone_number and masked_number when entering the match_phone_to_masked_phone function...
With a "normal" Apple account (not having this issue):
With an "affected" Apple account (having the issue):
I did try setting those env vars, but it didn't help:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Description
The change simply adds the NBSP character to the list of characters to be removed from the phone number, so that when Apple somehow sends you the NBSP character with your phone number, the 2FA will still work.
Testing Steps
I've tested this locally on my machine and it fixed the problem for me. Unfortunately it is impossible for me to provide reproduction steps since the issue is random and specific to my Apple account. Things work perfectly fine on other Apple accounts. I don't know what triggers this, but I'm thinking other Apple accounts could encounter this too.
Added the non-breaking space character (0xa0) to the characters to be removed from the phone number in the match_phone_to_masked_phone function.
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
It can happen that the phone number returned by Apple contains NBSP characters. When it does, the step of selecting the phone number automatically from the
SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER
env var fails with this message:This issue is very weird, we have several different Apple accounts, most of which don't have this issue. This problem only happens on a single specific Apple account, and it doesn't even happen consistently.
When I got stuck with the problem on my machine, I did some debugging by modifying my Fastlane installation files manually and found the source of the problem like this.
This is the output of printing the
phone_number
andmasked_number
when entering thematch_phone_to_masked_phone
function...With a "normal" Apple account (not having this issue):
With an "affected" Apple account (having the issue):
I did try setting those env vars, but it didn't help:
Description
The change simply adds the NBSP character to the list of characters to be removed from the phone number, so that when Apple somehow sends you the NBSP character with your phone number, the 2FA will still work.
Testing Steps
I've tested this locally on my machine and it fixed the problem for me. Unfortunately it is impossible for me to provide reproduction steps since the issue is random and specific to my Apple account. Things work perfectly fine on other Apple accounts. I don't know what triggers this, but I'm thinking other Apple accounts could encounter this too.