aws-amplify / aws-amplify/amplify-cli
Bug: synthesizer fails due to automatically added system hidden files, error does not contain a message
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
Hello,
After debugging my issue I've found, that function `validateFilesAndReturnPath()` from `export-backend-asset-handler` file fails due to this check:
```
const allFiles = fs.readdirSync(filePath);
if (allFiles?.length > 1) {
throw new Error();
}
```
I see 2 issues there:
1. Firstly, error doesn't have description. If you get it (like I did), then CDK synthesizer will just throw an error without any description, which is very user non friendly.
2. And the root cause - if there are automatically generated files, like for example `.DS_Store` file on Mac, then it will fail, because number of files found is greater than 1.
I believe this might be a common issue, since you need to unzip function package manually and then zip it again, if you want to change anything in Lambda function, which is a story for another GitHub issue. I'm not sure, but I believe this file is created after that operation.
Contributor guide
Research direction
Start in the export-backend-asset-handler file at validateFilesAndReturnPath(), especially the fs.readdirSync(filePath) check. Reproduce the failure with an automatically generated hidden file such as .DS_Store and inspect the resulting error. Done means valid Lambda package handling no longer fails solely because of that file, and failures include a useful message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100