amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

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

Open attilah opened this issue 4 years ago • 2 comments

Before opening, please confirm:

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

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)

# Put schemas below this line


Log output

# Put your logs below this line


Additional information

No response

attilah avatar Nov 17 '21 18:11 attilah

Why would you override auth on an empty project?

kaustavghosh06 avatar Nov 17 '21 19:11 kaustavghosh06

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.

josefaidt avatar Sep 19 '22 19:09 josefaidt