amplify-cli: Failed to authenticate: `Cannot read property 'message' of undefined`

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

curl

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

v18.2.0

Amplify CLI Version

9.1.0

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.

No

Amplify Categories

Not applicable

Amplify Commands

pull

Describe the bug

Following intro tutorial I tried doing a pull

amplify pull --appId <app_id> --envName staging

I was presented with a prompt for authentication

Confirm login in the browser or manually paste in your CLI login key:

and the site was opened https://us-east-2.admin.amplifyapp.com/admin/<app_id>/staging/verify/?loginVersion=1 in Safari.

After copying and pasting the key I received error

Failed to authenticate: Cannot read property 'message' of undefined

and a new prompt

? Select the authentication method you want to use: Amplify Studio

After that I got a new error message

Failed to get credentials: Current environment cannot be determined
Use 'amplify init' in the root of your app directory to initialize your project with Amplify

amplify pull --appId <app_id> --envName staging now ends up in

🛑 File at path: '/Users/plisy/source/plisy/react-amplified/amplify/cli.json' does not exist
Error: File at path: '/Users/plisy/source/plisy/react-amplified/amplify/cli.json' does not exist
    at Function.readJson (/snapshot/repo/build/node_modules/amplify-cli-core/lib/jsonUtilities.js:40:19)
    at StateManager.getData (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:309:56)
    at StateManager.getCLIJSON (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:254:25)
    at DebugConfig.getCLIJson (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:31:48)
    at DebugConfig.writeShareProjectConfig (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:44:30)
    at DebugConfig.setAndWriteShareProject (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:66:14)
    at reportError (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/diagnose.js:55:49)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:168:13)

like #10686

The project was initially pulled from a sandbox with amplify pull --sandboxId <sandbox_id>

Expected behavior

Authenticated without errors, things get pulled.

Reproduction steps

N/A

GraphQL schema(s)

# Put schemas below this line


Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

as a workaround are you able to set your default browser to something like Firefox or Chrome while running the amplify pull... command?