aws-amplify / aws-amplify/amplify-cli

Improve the error flow for non-initialized project

Open
#2,545 3 comments 1 reaction 0 assignees View on GitHub
bug p3 platform size-sm
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

If I do `amplify add xxx` in a project which hasn't been initialized we currently spit out an ugly trace:

```
authtest $amplify-dev add auth
Scanning for plugins...
Plugin scan successful
You are not working inside a valid amplify project.
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
Error: You are not working inside a valid amplify project.
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
at getAmplifyDirPath (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/extensions/amplify-helpers/path-manager.js:49:11)
at getDotConfigDirPath (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/extensions/amplify-helpers/path-manager.js:53:37)
at Object.getProjectConfigFilePath (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/extensions/amplify-helpers/path-manager.js:81:37)
at AmplifyToolkit.getProjectDetails [as _getProjectDetails] (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/extensions/amplify-helpers/get-project-details.js:7:45)
at Object.run (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-category-auth/commands/auth/enable.js:15:34)
at Object.executeAmplifyCommand (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-category-auth/index.js:318:23)
at /Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/execution-manager.js:114:55
at step (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/execution-manager.js:33:23)
at Object.next (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/execution-manager.js:14:53)
at fulfilled (/Users/richardthrelkeld/Downloads/adminauth/amplify-cli/packages/amplify-cli/lib/execution-manager.js:5:58)
at
```

Why don't we either:
- Automatically prompt to run amplify init (y/N)
- Remove this stack trace since it's obfuscating the message about running amplify init

Contributor guide

Open the contributing guide

Research direction

Reproduce `amplify add auth` outside an initialized project, then trace the error through `packages/amplify-cli/lib/extensions/amplify-helpers/path-manager.js`, `get-project-details.js`, and `lib/execution-manager.js`. Compare the current output with the issue's proposed init prompt or concise error handling. Done means the user receives clear guidance without an obfuscating stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.