build: non-tag images self-report an empty version (option_env! sees Some(""))
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 157
- Forks
- 32
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 145
Description
Observed while validating #967 (pre-existing, not introduced there).
Dockerfile declares ARG BUILD_VERSION= and materializes it as ENV AISIX_BUILD_VERSION=$BUILD_VERSION unconditionally, so every non-tag build (main :dev, :poc, workflow_dispatch, plain local docker build) compiles with AISIX_BUILD_VERSION set to the EMPTY STRING. crates/aisix-core/src/version.rs:14 uses option_env!, which returns Some("") for a set-but-empty variable, so the documented fallback to CARGO_PKG_VERSION never triggers:
docker run --rm --entrypoint /usr/local/bin/aisix ghcr.io/api7/aisix:dev --version
aisix
(bare aisix, no version — likewise the Server header and heartbeat dp_version on those builds).
Tag builds pass a real BUILD_VERSION and are unaffected; the tag-time version check only runs on tags, so this never trips CI.
Fix direction: treat empty as unset, e.g. a match arm Some(v) if !v.is_empty() (const-compatible via manual byte-len check) or guard the ENV in the Dockerfile. The unit test at version.rs:24 asserts non-empty but only runs against the crate-version fallback in CI, which is why it never caught this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Dockerfile and crates/aisix-core/src/version.rs:14, then read the unit test at version.rs:24. Reproduce a non-tag build where AISIX_BUILD_VERSION is empty and verify that the crate-version fallback is used. Done means --version, the Server header, and heartbeat dp_version report a non-empty version for non-tag builds while tag builds remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dockerfile, rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100