Skip to content

fix(test): stop pinning the tracer scope name to a development build - #4109

Merged
Umang01-hash merged 1 commit into
developmentfrom
fix/tracer-scope-name-pins-dev-version
Aug 31, 2026
Merged

fix(test): stop pinning the tracer scope name to a development build#4109
Umang01-hash merged 1 commit into
developmentfrom
fix/tracer-scope-name-pins-dev-version

Conversation

@aryanmehrotra

@aryanmehrotra aryanmehrotra commented Aug 31, 2026

Copy link
Copy Markdown
Member

Description:

Test_TracerContract_InstrumentationScopeName asserts the instrumentation scope name equals the literal "gofr-dev". The middleware builds that name as "gofr-" + version.Framework (tracer.go:64), and version.Framework is "dev" only on a development build — a release branch sets it to the version being cut.

So the test passes on development and fails on every release branch:

    tracer_test.go:436
    Error:      Not equal:
                expected: "gofr-dev"
                actual  : "gofr-v1.60.0"
--- FAIL: Test_TracerContract_InstrumentationScopeName (0.00s)
FAIL	gofr.dev/pkg/gofr/http/middleware

Found while cutting v1.60.0 (#4107), where it failed all three PKG Unit Testing shards — v1.24, v1.25 and v1.26. It is the only failure in ./pkg/....

This is a same-cycle regression, not inherited debt. The assertion arrived with #3770 (7cbb41a3), which is itself part of the v1.60.0 release:

v1.59.0 v1.60.0 (development)
"gofr-dev" literal in tracer_test.go absent present
version.Framework referenced by that test never yes

tracer_test.go predates this cycle, but nothing in it depended on the version until #3770, so v1.59.0's release branch could not have hit this. v1.60.0 is the first release that would fail — and so would every release after it, if this shipped as is. Fixing it at the source rather than patching the release branch keeps the next cut clean.

Why the literal was never load-bearing

The two assertions were:

assert.Equal(t, "gofr-dev", tracerCharScopeName(),
    "version.Framework changed; the scope name below moves with it")
assert.Equal(t, tracerCharScopeName(), spans[0].InstrumentationScope().Name)

with tracerCharScopeName() defined as "gofr-" + version.Framework. The second line already pinned the contract — the span's scope name is the gofr prefix plus the framework version. The first only asserted that this particular build happens to be a development build, which is a property of the branch, not of the middleware.

Its comment shows the intent was a tripwire for the name moving. But the name is designed to move with every release, so the tripwire fires on exactly the occasions when nothing is wrong.

The change

The expected value is derived the way production derives it, and a second assertion pins that the version is actually appended rather than resolving to an empty string — the one failure mode a derived expectation could otherwise hide:

assert.Equal(t, "gofr-"+version.Framework, spans[0].InstrumentationScope().Name,
    "scope name is the gofr- prefix plus version.Framework")
assert.NotEqual(t, "gofr-", spans[0].InstrumentationScope().Name,
    "the version must actually be appended, not an empty string")

tracerCharScopeName is removed; it had no other caller.

Breaking Changes (if applicable):

None. Test-only change; no production file is touched.

Additional Information:

The assertion was checked in both directions rather than assumed to work.

Mutation-verified against the production expression in tracer.go:

production expression result
"gofrx-" + version.Framework FAIL
"gofr-" + "" FAIL
unmodified PASS

(A third mutation — deleting version.Framework outright — was discarded because it leaves the import unused and fails to build, so it tests nothing.)

Verified under both builds, which is the point of the change:

  • Framework = "dev"go test ./pkg/gofr/http/middleware/ -run Test_TracerContract green.
  • Framework = "v1.60.0" → green (fails on development today).

go vet ./pkg/gofr/http/middleware/ is clean.

golangci-lint run ./pkg/gofr/http/middleware/... reports 5 findings, none in the changed file — 2 goconst in logger.go and 3 noctx in apikey_auth_test.go / auth_test.go, all pre-existing in files this PR does not touch (the diff is tracer_test.go alone, +8/-7). CI runs with only-new-issues, and Code Quality passes.

On the full local go test ./pkg/...: one package fails on my machine, pkg/gofr/datasource/pubsub/mqtt, which hangs to a test timed out panic at both the default and a 5m timeout. It talks to a public MQTT broker, this PR does not touch it (the diff is tracer_test.go alone), and it passes in CI. I am citing CI as the authority rather than my own run: all three PKG Unit Testing shards pass on this branch, which is precisely the check that was red on the release branch.

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests. — the change is the test; verified by mutation in both directions
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Test_TracerContract_InstrumentationScopeName asserted the instrumentation
scope name equals the literal "gofr-dev". The middleware builds that name as
"gofr-" + version.Framework, and version.Framework is "dev" only on a
development build — a release branch sets it to the version being cut.

So the test passes on development and fails on every release branch:

    tracer_test.go:436
    expected: "gofr-dev"
    actual  : "gofr-v1.60.0"

Found on release/v1.60.0, where it failed all three PKG Unit Testing shards.
It would have failed the same way on v1.61.0 and every release after.

The literal was doing no work the surrounding assertions did not already do.
Line 438 compared the span's scope name to tracerCharScopeName(), which is
itself "gofr-" + version.Framework, so the contract was already pinned; the
literal only added an assertion that this build happens to be a dev build.

The expected value is now derived the same way the production code derives it,
and a second assertion pins that the version is actually appended rather than
resolving to an empty string — the failure mode a derived expectation could
otherwise hide. tracerCharScopeName is gone, since it had no other caller.

Mutation-verified against the production expression in tracer.go:
  "gofrx-" + version.Framework  -> FAIL
  "gofr-"  + ""                 -> FAIL
  unmodified                    -> PASS

Verified under both builds: green with Framework = "dev" and with
Framework = "v1.60.0".
@Umang01-hash
Umang01-hash merged commit c817f71 into development Aug 31, 2026
19 checks passed
@Umang01-hash
Umang01-hash deleted the fix/tracer-scope-name-pins-dev-version branch August 31, 2026 09:03
aryanmehrotra added a commit that referenced this pull request Aug 31, 2026
* Merge pull request #3815 from akshat-kumar-singhal/fix/flaky-cron-nil-logger-sql-mock-3813

fix(cron): join in-flight jobs on Stop and skip jobs with no logger

* chore(ci): pin ls-lint/action to node24 commit to clear Node 20 warning (#3864)

v2.3.1 declares `using: node20`, so every Linting Party run emits the
Node.js 20 deprecation warning. Upstream fixed it in 0c7f19c ("chore: run
on the node24 runtime"), but no release carries it yet, so pin the SHA.
Revert to a tag once ls-lint cuts a release with the node24 runtime.

Co-authored-by: Aryan Mehrotra <aryanmehrotra2000@gmail.com>

* fix(grpc): guard the server handle so Run and Shutdown stop racing (#3929) (#3931)

* chore(ci): build the website workflows on Node 24 instead of EOL Node 18 (#3870) (#3871)

Node 18 "Hydrogen" reached end-of-life on 2025-04-30 and receives no
security patches, including for the bundled OpenSSL and undici. The
prod and stage website workflows build and deploy gofr.dev — they run
`yarn install --frozen-lockfile` and `yarn refresh-data` against the
network while holding the GAR deployment key and `packages: write`.

Targets 24.x rather than the 22.x the issue suggested: v22 has been in
maintenance since 2025-10-21 while v24 is the Active LTS through
2028-04-30. Verified `yarn install --frozen-lockfile` is green on
node:24-alpine against the website's current lockfile.

Both files changed together so prod and stage don't drift.

Co-authored-by: Aryan Mehrotra <aryanmehrotra2000@gmail.com>

* fix(examples): wait on a readiness signal instead of sleeping, and make using-migrations self-contained (#3818, #3816) (#3821)

* feat(ai): add Embed capability to the LLM (#3757)

* perf(http): opt-in O(1) trie router behind GOFR_ROUTER (#3759)

* chore(deps): consolidate minor/patch dependency updates (2026-08-18) (#3969)

* fix(ci): wait for Example-Unit-Testing services to be ready, and pin Zipkin (#3868) (#3939)

* chore(ci): add concurrency groups and job timeouts, pin actions by SHA (#3865, #3867) (#3936)

* fix(ci): stop mutating go.mod mid-run; check submodule tidiness without writing (#3869) (#3938)

* chore(deps): close the dependabot coverage gaps and retire EOL base images (#3873) (#3937)

* chore(deps): bump tj-actions/changed-files 47.0.0 -> 47.0.6 (#4049)

* chore(deps): bump redis/go-redis/v9 9.21.0 -> 9.22.0 + regenerate mock (#4051)

* chore(deps): bump golang 1.26-alpine -> 1.27-alpine in examples/http-server (#4098)

Docker base image bump from Dependabot #4064 (docker group).

Closes: #4064

Co-authored-by: claude-flow <ruv@ruv.net>

* fix(http): characterize the request path and fix eleven defects it exposed (#3770)

* perf(logging,http): skip request logs the level discards, and co-allocate the request objects (#3974)

* update release version to v1.60.0

* fix(ai): make Embed a method on ai.LLM instead of a type assertion (#4108)

* fix(test): stop pinning the tracer scope name to a development build (#4109)

---------

Co-authored-by: Akshat Singhal <65562230+akshat-kumar-singhal@users.noreply.github.com>
Co-authored-by: Umang Mundhra <mundhraumang.02@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants