aws-amplify / aws-amplify/amplify-cli

receiving `cannot read property 'accessKeyId' of undefined` after a failed Studio auth attempt

Open
#12,184 1 comment 1 reaction 0 assignees View on GitHub
bug p2 platform
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

pnpm

### If applicable, what version of Node.js are you using?

18

### Amplify CLI Version

11.0.0-beta.8

### What operating system are you using?

mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

n/a

### Describe the bug

We are attempting to pull a project by specifying an environment that does not exist. After failing to authorize with Amplify Studio we want to use an AWS Profile, but are receiving an error:

```
➜ amplify pull --appId d2hsgs8prp2v7v --envName prod
Opening link: https://us-east-1.admin.amplifyapp.com/admin/d2hsgs8prp2v7v/prod/verify/?loginVersion=1
⠸ Confirm login in the browser or manually paste in your CLI login key:

🛑 Failed to authenticate with Amplify Studio: Provided token was invalid.
? Select the authentication method you want to use: AWS profile
🛑 Failed to get profile credentials
Cannot read property 'accessKeyId' of undefined

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: 7690f8ca-7b09-424f-9b0f-a5cafc23fff9
```

### Expected behavior

We are able to proceed with AWS Profile

### Reproduction steps

1. from the AWS Console for AWS Amplify, create a new app (this will create a "staging" env)
2. copy the provided `amplify pull...` command
3. in an empty directory, paste the copied pull command and attempt to pull a different environment such as "production"
```diff
- amplify pull --appId d2hsgs8prp2v7v --envName staging
+ amplify pull --appId d2hsgs8prp2v7v --envName production
```
4. the CLI will prompt to auth with Amplify Studio, however this environment does not exist. Proceed with Enter
5. Studio auth will fail and the CLI prompts for a different method, let's choose `AWS Profile`
6. observe error

### Project Identifier

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

### Before submitting, please confirm:

- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `amplify pull --appId d2hsgs8prp2v7v --envName production` after Studio authentication fails, then trace the AWS Profile fallback that reports undefined credentials. Done means selecting AWS Profile proceeds without the `accessKeyId` error and the documented reproduction no longer fails at that point.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript
Domain
authentication, cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.