ENG-3757: Fix Fides.version showing dev decorations on tagged Docker builds#8147
Conversation
`.dockerignore` excludes files that the host's `.git/index` tracks, so the COPYed tree always looks dirty to setuptools-scm. On tagged release builds that caused `version.json` (and Fides.version in the JS bundle) to be decorated as `<next>.devN+g<sha>.d<date>` instead of the actual tag. When HEAD is exactly on a tag, force setuptools-scm to use that tag verbatim via `SETUPTOOLS_SCM_PRETEND_VERSION` -- the same approach the wheel build already uses in .github/workflows/publish_package.yaml. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8147 +/- ##
=======================================
Coverage 85.23% 85.23%
=======================================
Files 638 638
Lines 42011 42011
Branches 4937 4937
=======================================
Hits 35807 35807
Misses 5096 5096
Partials 1108 1108 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/code-review |
There was a problem hiding this comment.
Code Review: Fix Fides version on tagged Docker builds
This is a clean, minimal fix for a real build-time problem. The root cause explanation in the new comment block is accurate and helpful — the .dockerignore exclusions cause setuptools-scm to see a dirty tree, which appends dev decorations to the version string on tagged release builds.
What the fix does
- Detects whether the current git HEAD lands exactly on a tag using
git describe --tags --exact-match. - If so, sets
SETUPTOOLS_SCM_PRETEND_VERSIONto that tag value, which bypasses setuptools-scm's git tree inspection entirely. - Falls through to normal
hatch versionbehavior for non-tagged builds (dev/CI builds continue to get the expecteddevN+g<sha>suffix).
Assessment
Correctness: The approach is sound and consistent with the wheel build workflow referenced in the comment. The || true ensures the RUN step doesn't fail on non-tagged commits. The if [ -n "$EXACT_TAG" ] guard correctly leaves the env var unset when not on a tag.
Shell semantics: export inside the if block within a single RUN command is correct — all commands in the layer share the same shell process, so the variable is visible to the subsequent hatch version call.
Tag format: See inline comment — worth a quick sanity check that the v-prefix behavior (if applicable) matches expectations, though setuptools-scm handles this correctly in practice.
Changelog: Entry is present and accurately describes the fix.
No blocking issues. LGTM with the minor note above.
🔬 Codegraph: connected (49514 nodes)
💡 Write /code-review in a comment to re-run this review.
gilluminate
left a comment
There was a problem hiding this comment.
tested locally, works exactly as expected. 👍
Ticket ENG-3757
Description Of Changes
Fides.version(the version exposed by the FidesJS SDK) andversion.json(its source inside the container) were being decorated with dev-style suffixes — e.g.2.84.6.dev0+g<sha>.d<date>— even on tagged release builds where the running container actually corresponds to a clean tag (e.g.2.84.5).Root cause: The Docker build copies the host's
.gitdirectory in but applies.dockerignoreto the worktree, so files tracked by the host's.git/indexare missing from the container's worktree.setuptools-scm(whichhatch-vcswraps) sees this as a dirty tree and applies itsdirty-tagheuristic — it bumps the version to the next patch, appends.dev0, and tacks on a local-version segment with the SHA and date. The previousversioneer-based version export was less aggressive about decorating dirty trees, so this regression landed quietly when the version step was switched tohatch versionin #7328 (the "Switch to uv" PR).The same problem already existed at PyPI publish time and was solved in
.github/workflows/publish_package.yamlby settingSETUPTOOLS_SCM_PRETEND_VERSIONfrom the tag. This PR applies the equivalent override inside the Dockerfile: when HEAD is on an exact tag, the env var is set to that tag andhatch versionreturns the tag verbatim. Off-tag builds are unaffected and continue to produce<next>.devN+g<sha>.d<date>so dev images remain uniquely identifiable.This also incidentally fixes the Python webserver's reported version on Docker images built outside of the PyPI publish pipeline (the
clean_version()regex insrc/fides/common/utils.pywas written forversioneer's output format and does not stripsetuptools-scm'sdev0+g<sha>.d<date>decoration). After this change, bothFides.version(frontend) and__version__(backend) report the clean tag on tagged Docker builds.Code Changes
Dockerfile— when HEAD is on an exact tag, setSETUPTOOLS_SCM_PRETEND_VERSIONfromgit describe --tags --exact-matchbefore invokinghatch version, mirroring the override already used in.github/workflows/publish_package.yaml. Comment added explaining the.dockerignoreinteraction so this isn't rediscovered later.Steps to Confirm
These steps verify both the tagged-release path (clean version) and the off-tag dev path (decorated version) inside the actual Docker build, since the dirty-tree behavior cannot be reproduced on the host.
Pull the branch and create a local test tag on the tip commit. A test tag is needed because the override only fires when HEAD is on an exact tag. Use any PEP 440-valid version string that doesn't collide with a real release:
Build the
backendstage of the Docker image. Targeting thebackendstage skips the frontend build and is sufficient for this verification —version.jsonis generated in this stage.Read
version.jsonfrom the built image. Expected: the clean tag, with no decoration.Expected output:
{"version": "99.99.99"}Pre-fix this would have returned:
{"version": "99.99.100.dev0+g<sha>.d<date>"}Verify the off-tag (dev) path still produces a sensible decorated version. Delete the tag and rebuild without cache so the version step re-runs:
Expected output: a string of the form
<next>.devN+g<sha>.d<date>(e.g.2.84.1b1.dev81+gcc93122c4.d20260508). This confirms dev images remain uniquely identifiable and the override is correctly scoped to tagged builds only.(Optional) End-to-end sanity check via FidesJS. Build the full image (no
--target), boot the privacy center / consent flow, and confirmFides.versionin the browser console matches the tag rather than a decorated dev string. This is the surface where the bug was originally observed but is not strictly necessary if theversion.jsonchecks above pass —version.jsonis the single input that flows into the JS bundle.Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works