Skip to content

create_template.sh produces null templateID for multi-line Dockerfiles #36

@renyuanc

Description

@renyuanc

Reproduction

Calling ./packages/create_template.sh --docker-file <path> 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions