Skip to content

Released container images report version "dev" from /health and /_localstack/info #402

Closed

Description

@scttfrdmn

Every published ghcr.io/scttfrdmn/substrate image reports "version":"dev" regardless of the tag, so a consumer cannot tell which build they are talking to.

Reproduce

$ podman run -d -p 4566:4566 ghcr.io/scttfrdmn/substrate:0.76.0
$ curl -s localhost:4566/health
{"status":"ok","version":"dev"}

Confirmed on 0.76.0, 0.75.0, and 0.70.0 — systemic across releases, not a one-off bad build.

Root cause

Dockerfile:10 injects the version into the root module path, which contains no Go files:

-X github.com/scttfrdmn/substrate.Version=${VERSION}

But the variable actually served by /health and /_localstack/{health,info} lives in the emulator package — emulator/doc.go:131:

var Version = "dev"

emulator/server.go:424 (handleHealth) and :325 (handleLocalStackHealth) both read that Version. -X on a package with no Go files is silently ignored by the linker — no warning, no build failure — so emulator.Version keeps its "dev" default.

Makefile:4 has the correct path, which is why locally-built binaries report the right version and container images do not:

LDFLAGS := -ldflags "-X main.version=$(VERSION) -X github.com/scttfrdmn/substrate/emulator.Version=$(VERSION)"

Note .github/workflows/docker.yml:44 does correctly pass build-args: VERSION=${{ github.ref_name }}, so the build wiring is fine — only the target symbol path is wrong.

Proof

Two binaries from the same tree at fa7684b (v0.76.0), differing only in the -X path:

$ go build -ldflags "-X main.version=0.76.0 -X github.com/scttfrdmn/substrate.Version=0.76.0" -o /tmp/sub-dockerfile ./cmd/substrate
$ go build -ldflags "-X main.version=0.76.0 -X github.com/scttfrdmn/substrate/emulator.Version=0.76.0" -o /tmp/sub-fixed ./cmd/substrate

$ curl -s localhost:4578/health   # Dockerfile path
{"status":"ok","version":"dev"}
$ curl -s localhost:4577/health   # emulator path
{"status":"ok","version":"0.76.0"}

Both builds succeeded — the bad -X produced no diagnostic.

Fix

Dockerfile:10 — add the /emulator path segment:

-    -ldflags "-X main.version=${VERSION} -X github.com/scttfrdmn/substrate.Version=${VERSION}" \
+    -ldflags "-X main.version=${VERSION} -X github.com/scttfrdmn/substrate/emulator.Version=${VERSION}" \

Two things worth doing alongside it, since the class of bug is "a typo in an ldflags path fails silently":

  1. .github/workflows/ci.yml:68 omits emulator.Version entirely (-X main.version=... only). That binary is not published, so it is cosmetic, but it will drift from the Makefile the same way.
  2. Guard it in CI. A smoke step that asserts the built image reports the expected version would have caught this at the first release. Something like test "$(curl -s localhost:4566/health | jq -r .version)" = "${GITHUB_REF_NAME}" in docker.yml after the build. Alternatively, have emulator.Version fall back to runtime/debug.ReadBuildInfo() so a VCS-stamped binary reports something real even when ldflags are wrong.

Impact

Downstream projects that pin a substrate image tag for reproducible CI cannot verify at runtime which version answered. In parsl-ephemeral-aws we are pinning ghcr.io/scttfrdmn/substrate:0.76.0 in both docker-compose.substrate.yml and the CI service container, and the health endpoint gives us no way to confirm the pin took effect — so a silently-wrong tag or a stale cached image would go unnoticed.

Related to the fidelity work in #391, #392, #393.

Activity

  1. added this to the v0.78.0 milestone on Jul 31, 2026
  2. added
    type: bug
    and removed on Jul 31, 2026
  3. scttfrdmn commented on Aug 1, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in #433, merged to main. Your diagnosis was exact — including that -X against the root module path links with no diagnostic — so the production change is the one-line one you wrote.

    Reproduced from a real image build before and after, since the flag path is easy to reason about wrongly:

    # pre-fix Dockerfile, VERSION=v9.99.99-imagetest
    $ curl -s .../health
    {"status":"ok","version":"dev"}
    $ substrate --version
    substrate version v9.99.99-imagetest      # correct — which is why this survived five releases
    
    # post-fix, same tree
    $ curl -s .../health
    {"status":"ok","version":"v9.99.99-imagetest"}

    Both of your follow-ups are in:

    .github/workflows/ci.yml stamped only main.version; it now stamps emulator.Version too.

    The CI guard, as scripts/check-version-stamping.sh / make version-check and a new Version Stamping job. It builds with the Dockerfile's own -ldflags — extracted from the file rather than restated, so the two cannot drift — and asserts the running server reports that version on /health, /_localstack/health and /_localstack/info. Two cheaper checks name the culprit when it fails: the Dockerfile and Makefile must stamp the same symbols, and every -X target must resolve via go doc. I verified the guard is load-bearing by reverting the Dockerfile: all three layers fire and it reproduces "version":"dev".

    Your docker.yml suggestion is there as well, close to what you proposed — it smoke-tests the image it just pushed against github.ref_name. That's the layer CI can't reach, since the VERSION build-arg wiring only exists in a real image build.

    One thing I did not take: the runtime/debug.ReadBuildInfo() fallback. It would make a wrong -X invisible again by papering over it, which is the failure mode that cost you this bug. It's a good idea on its own merits for go install-ed binaries though — worth its own issue if you want that, distinct from release-image stamping.

    Note this ships in the next release, not retroactively: published tags are immutable (a moved tag breaks go.sum verification for every consumer), so 0.76.0 and every existing image will keep reporting "dev". Once the next tag is cut, curl .../health | jq -r .version becomes a real pin check for parsl-ephemeral-aws. Until then, substrate --version inside the container is accurate — docker run --rm --entrypoint /usr/local/bin/substrate ghcr.io/scttfrdmn/substrate:0.76.0 --version — if you want to verify a pinned image today.

    Also worth flagging while you're pinning images: no GitHub Release objects exist for v0.80.0 or v0.81.0 (the tags and images are published; only the Release pages are missing), so gh release list under-reports the latest version. Tracking that separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions