aws-samples / aws-samples/sample-e2b-on-aws
create_template.sh produces null templateID for multi-line Dockerfiles
- Dominant language
- Go
- Stars
- 86
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
**Reproduction**
Calling `./packages/create_template.sh --docker-file ` with any Dockerfile
that has more than one line (i.e., almost all real Dockerfiles) results in:
- The API returning an empty body
- Downstream `jq -r '.templateID'` producing the literal string `"null"`
- ECR push attempts landing at `e2bdev/base/null:null`
- Subsequent build polling spinning forever on status `null`
**Minimal reproducer**
Run ./packages/create_template.sh --docker-file Dockerfile against any
deployed stack. Observe the Response: line is empty/malformed.
**Root cause**
In packages/create_template.sh:78-89, the curl -d body is built via
naive bash JSON interpolation:
-d "{
\"readyCmd\": \"$READY_COMMAND\",
...
\"dockerfile\": \"$DOCKERFILE\",
...
}"
When $DOCKERFILE contains literal newlines (any multi-line Dockerfile),
the resulting body is invalid JSON: newlines are unescaped inside a JSON
string, and any " inside the Dockerfile (e.g., RUN echo "hello")
prematurely terminates the dockerfile field.
**Fix proposed**
Replace the bash interpolation with jq -n --arg dockerfile "$DOCKERFILE" ...
which handles all valid Dockerfile content correctly (newlines, quotes,
backslashes). Falls back to Python json.dumps() when jq is unavailable
(though jq is already a hard dependency elsewhere in the script, so the
fallback is mostly belt-and-suspenders).
I'd like to send a PR for this — happy to make any structural adjustments
the maintainers prefer.
Contributor guide
Assessment
This issue has not been assessed yet.