Repository navigation
fix(docker): stamp emulator.Version so images report their release (#402) - #433
Merged
Merged
Conversation
) The Dockerfile stamped `github.com/scttfrdmn/substrate.Version` — the root module path, which contains no Go files. The variable /health and /_localstack/{health,info} actually serve is `github.com/scttfrdmn/substrate/emulator.Version`, so every published image since those endpoints existed reported "dev". The linker silently ignores -X against a symbol that does not exist: no warning, no non-zero exit, the variable just keeps its default. Confirmed by building the same tree both ways — both builds succeeded, one reported the version and one reported "dev". `substrate --version` reads main.version and was always correct, which is why this survived five releases unnoticed. Consumers pinning an image tag for reproducible CI had no runtime way to confirm which build answered, so a silently-wrong tag or a stale cached image looked identical to a fresh pull. Guarded at all three layers, because the failure mode is a typo that links cleanly: - scripts/check-version-stamping.sh (make version-check, run by CI) builds with the Dockerfile's own -ldflags and asserts the server reports that version over HTTP. It also fails if the Dockerfile and Makefile stamp different symbols, and if any -X names a symbol that does not exist. It asserts the observable outcome rather than the spelling of the flag, since the spelling checks can only catch mistakes we thought of. - docker.yml smoke-tests the image it just pushed against the tag being released — the build-arg wiring only a real image can exercise. - ci.yml's build job now stamps emulator.Version too; it previously omitted it and would have drifted from the Makefile the same way. Verified the guard is load-bearing: reverting the Dockerfile to the buggy path fails all three of its layers and reproduces `{"status":"ok","version":"dev"}` from a real image build, while the fixed image reports the sentinel from the CLI and all three endpoints. Closes #402
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Aug 1, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #402, exactly as diagnosed in the issue:
Dockerfilestamped the root module path, which has no Go files.Why it was invisible
go build -Xagainst a symbol that does not exist links cleanly — no warning, no non-zero exit. The variable keeps its default. Andsubstrate --versionreadsmain.version, which was always stamped correctly, so the binary looked fine; only the HTTP endpoints were wrong.Reproduced from a real image build rather than by reading the flag:
Guards
The one-line fix is trivial; keeping it fixed is the actual work, since the failure mode is a typo that compiles. Three layers, each catching what the others cannot:
scripts/check-version-stamping.sh— new, wired up asmake version-checkand a CI job. It builds with the Dockerfile's own-ldflags(extracted from the file, not restated) and asserts the running server reports that version over HTTP. Plus two cheaper checks that name the culprit: Dockerfile and Makefile must stamp the same symbols, and every-Xtarget must resolve viago doc. The runtime assertion is the load-bearing one — the spelling checks only catch mistakes I thought of.docker.yml— smoke-tests the image it just pushed againstgithub.ref_name. This is the layer CI cannot reach: theVERSIONbuild-arg wiring only exists in a real image build.ci.yml— the build job omittedemulator.Versionentirely. Cosmetic today (that binary isn't published) but it would have drifted from the Makefile the same way, andmake version-checkwould now fail on it.Verified the guard is load-bearing rather than decorative — reverting
Dockerfileto the buggy path:All three layers fire independently.
Docs
emulator/doc.go—Version's comment now gives the exact-Xpath and warns that a wrong one fails silently, since that comment is what someone writing a new build recipe will read.docs/getting-started.md— the/healthexamples showed{"status":"ok"}, omitting the field this issue is about. They now showversion, with a note that it identifies the build answering (the reporter's use case: verifying a pinned tag in CI) and that a plaingo buildreportsdev.Not done
The issue's alternative suggestion — falling back to
runtime/debug.ReadBuildInfo()so a VCS-stamped binary self-reports — is deliberately skipped. It would mask a broken-Xrather than surface it, and the CI/release guards make the ldflags path reliable. Worth its own issue if you wantgo install-ed binaries to report a version.Verification
gofmt,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race),test/e2e,make docs-reference-check docs-versions version-check— all clean.shellcheckclean on the new script, matchingcheck-doc-versions.sh. Both workflow files re-parsed as YAML after editing. Image built and run both ways with podman, as shown above.Closes #402