aws-amplify / aws-amplify/amplify-cli

amplify state file with added commands fails push and cicd build

Open
#13,216 1 comment 0 reactions 0 assignees View on GitHub
bug functions p3
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?

_No response_

### Amplify CLI Version

12.4.0

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

well amplify.state is custom

### Describe the bug

When creating a function with custom build script in `amplify.state`.

say we add the build scripts with` npm install && echo 'hello world'` the push and build will fail

![image](https://github.com/aws-amplify/amplify-cli/assets/87995712/eba1f9f5-e7e6-446f-ab30-36b1d952c8b0)
![image](https://github.com/aws-amplify/amplify-cli/assets/87995712/705ef39d-46a6-415e-8c02-bfaf26360684)

but it appears adding the echo at the start(for example) will not throw the error.

### Expected behavior

document and fix if this is not expected

### Reproduction steps

1. amplify init
2. amplify add function -> `Choose the package manager that you want to use: ` as custom or any manager
3. in the `amplify.state` add say

```
{
"pluginId": "amplify-nodejs-function-runtime-provider",
"functionRuntime": "nodejs",
"useLegacyBuild": true,
"defaultEditorFile": "src/index.js",
"scripts": {
"build": "npm install && "echo 'hello world'"
}
}
```
4. amplify push and observe error

### 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

Open the contributing guide

Research direction

Reproduce the failure with the documented amplify init, amplify add function, and amplify push steps, using the custom scripts.build value in amplify.state. Start by tracing how that state entry is handled during the function build, then verify whether push and CI/CD builds succeed or the expected behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.