#4066·opencost

Release images are built from the previous patch release (checkout of moving vX.Y tag)

Author: PoilCreated Sep 23, 2026Updated Sep 23, 2026

Describe the bug

Since at least v1.120.4, the release image published as ghcr.io/opencost/opencost:X.Y.Z does not contain the code of tag vX.Y.Z. It contains the code of the previous patch release. This is what turned #4048 into a crash: the fix from #4015 is in the v1.121.2 tag, but not in the 1.121.2 image.

Build commit embedded in each image, read from /go/bin/app (arm64). For 1.121.2 it also matches the startup log Starting cost-model version 1.121.2 (2fdd987):

image tag vX.Y.Z points to commit embedded in the image =
1.120.4 1741baa 85c87a3 v1.120.3
1.121.0 f5fc438 f5fc438 ok
1.121.1 2fdd987 f5fc438 v1.121.0
1.121.2 e22df84 2fdd987 v1.121.1
1.121.3 2f1af7f e22df84 v1.121.2

A code-level check agrees: the 1.121.2 binary contains config.ConfUnmarshaller (the pre-#4015 type), and the 1.121.3 binary contains config.confUnmarshaller, which is what the v1.121.2 tag introduced.

Root cause

.github/workflows/build-and-publish-release.yml is triggered by the vX.Y.Z tag push, but it does not build that tag. It builds the ref vX.Y:

yaml
      - name: Make Branch Name
        id: branch
        run: |
          echo "BRANCH_NAME=v${RELEASE_VERSION%.*}" >> $GITHUB_OUTPUT

      - name: Checkout Repo
        uses: actions/[email protected]
        with:
          ref: '${{ steps.branch.outputs.BRANCH_NAME }}'

There is no v1.121 branch. v1.121 is a tag that is moved forward by hand after each patch release, and it is moved after the vX.Y.Z tag push has already started the build:

release vX.Y.Z release run started vX.Y tag moved to the new commit
v1.121.3 2026-09-16T21:21:11Z 2026-09-16T21:34:54Z (v1.121 → 2f1af7f)
v1.120.4 2026-06-25T18:51:25Z 2026-06-25T19:31:59Z (v1.120 → 1741baa)

So the checkout resolves vX.Y to where it pointed before, i.e. the previous patch release. 1.121.0 is correct because its release workflow ran twice (16:31 and 17:31), presumably once before and once after v1.121 was created.

The image still gets tagged X.Y.Z and reports version X.Y.Z, so nothing looks wrong until a fix that is "in the release" turns out to be missing.

Suggested fix

For tag-triggered runs, check out the tag that triggered the workflow. Keep the computed ref only for workflow_dispatch:

yaml
      - name: Checkout Repo
        uses: actions/[email protected]
        with:
          ref: ${{ github.event_name == 'push' && github.ref || steps.branch.outputs.BRANCH_NAME }}

A cheap guard would also help: fail the job when git rev-parse HEAD differs from git rev-parse "v${RELEASE_VERSION}^{commit}".

Once fixed, 1.121.1, 1.121.2 and 1.121.3 probably need rebuilding from their tags.

Side note: starting with 1.121.2, the images are also built with go1.27.1 (go version -m /go/bin/app), while 1.121.1 used go1.26.5 and go.mod says go 1.26.4. The old type ConfUnmarshaller *Configurations idiom recurses under Go 1.27's encoding/json, and that is the #4048 stack overflow. The older code alone would have been harmless.

Which version of OpenCost are you using? 1.120.4 → 1.121.3 (release images on ghcr.io)