aws-amplify / aws-amplify/amplify-cli
Syntax errors should list filename, not just line number
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
18.7.1
### Amplify CLI Version
12.4.0
### What operating system are you using?
Ubuntu on WSL2
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
Many, but not directly relevant.
### Describe the bug
I've attached the result of running amplify push --debug. It lists a syntax error. It would be a better developer experience if it also listed the filename. This issue could either be considered a bug or a feature request that syntax errors list filenames. I was eventually able to find the file.
🛑 Syntax error, found trailing characters at line 85,4 >>> },
"Conditions": ...
Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
UnknownFault: Syntax error, found trailing characters at line 85,4 >>> },
"Conditions": ...
at genericErrorToAmplifyException (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/amplify-exception-handler.js:126:49)
at handleException (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/amplify-exception-handler.js:27:28)
at process. (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:52:93)
at process.emit (node:events:513:28)
at process._fatalException (node:internal/process/execution:149:25)
Syntax error, found trailing characters at line 85,4 >>> },
"Conditions": ...
Error: Syntax error, found trailing characters at line 85,4 >>> },
"Conditions": ...
at error (/snapshot/amplify-cli/build/node_modules/hjson/lib/hjson-parse.js:41:11)
at checkTrailing (/snapshot/amplify-cli/build/node_modules/hjson/lib/hjson-parse.js:402:13)
at legacyRootValue (/snapshot/amplify-cli/build/node_modules/hjson/lib/hjson-parse.js:428:24)
at Object. (/snapshot/amplify-cli/build/node_modules/hjson/lib/hjson-parse.js:454:23)
at JSONUtilities.parse (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-cli-core/lib/jsonUtilities.js:94:27)
at readCFNTemplate (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-cli-core/lib/cfnUtilities.js:48:64)
at ensureLambdaExecutionRoleOutputs (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-function/lib/provider-utils/awscloudformation/utils/ensure-lambda-arn-outputs.js:42:72)
at prePushHandler (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-function/lib/events/prePushHandler.js:22:76)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.handleAmplifyEvent (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-function/lib/index.js:284:13)
at async eventHandler (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:288:17)
at async raiseEvent (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:293:13)
at async raisePrePushEvent (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:220:5)
at async raisePreEvent (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:202:13)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:136:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
Session Identifier: 39032150-686c-4deb-a0fe-9b39701461c8
✅ Report saved: /tmp/genepanelapi/report-1695080474353.zip
✔ Done
Project Identifier: 0ccea735cf5b2d0ed9f7c2d4ecfb887c
### Expected behavior
Syntax errors, and other appropriate errors, list filenames where the syntax error is encountered
### Reproduction steps
1. Find any working cloudformation template for a function.
2. Add a spurious "},"
3. Run amplify push
### 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
Research direction
Reproduce the malformed CloudFormation template with amplify push, then trace the error through JSONUtilities.parse and readCFNTemplate as shown in the stack trace. Done means syntax errors report the filename alongside the line and column information, with the existing reproduction still producing a useful error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100