aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.82k stars 818 forks source link

override auth fails in empty projects: Cannot convert undefined or null to object #8922

Open attilah opened 2 years ago

attilah commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

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

14

Amplify CLI Version

7.x

What operating system are you using?

macos

Amplify Categories

auth

Amplify Commands

Not applicable

Describe the bug

override auth fails when project has no resources:

Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.run (/Users/attila/workspaces/amplify-cli/packages/amplify-category-auth/lib/commands/auth/override.js:17:12)
    at Object.executeAmplifyCommand (/Users/attila/workspaces/amplify-cli/packages/amplify-category-auth/lib/index.js:336:25)
    at /Users/attila/workspaces/amplify-cli/packages/amplify-cli/lib/execution-manager.js:203:51
    at executePluginModuleCommand (/Users/attila/workspaces/amplify-cli/packages/amplify-cli/lib/execution-manager.js:187:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.executeCommand (/Users/attila/workspaces/amplify-cli/packages/amplify-cli/lib/execution-manager.js:35:9)
    at async Object.run (/Users/attila/workspaces/amplify-cli/packages/amplify-cli/lib/index.js:162:9)

Expected behavior

Provide proper error message

Reproduction steps

  1. amplify init
  2. amplify add override

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line ```

Additional information

No response

kaustavghosh06 commented 2 years ago

Why would you override auth on an empty project?

josefaidt commented 2 years ago

I've changed this to a bug for the error and stack trace. It would be helpful if the CLI failed faster and did not allow us to run amplify override auth in a project where auth is not already present.