Skip to content

fix: report a single semantic version in the user agent - #132

Merged
simonmarty merged 1 commit into
masterfrom
fix_version_info
Aug 5, 2026
Merged

fix: report a single semantic version in the user agent#132
simonmarty merged 1 commit into
masterfrom
fix_version_info

Conversation

@SaiTejaKundety

@SaiTejaKundety SaiTejaKundety commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Why is this change being made?

  1. The version constant did not match what we actually publish. It was built from four separate constants that produced a four-part string like 2.0.2.0, while every release tag and the pkg.go.dev version are three parts (v2.2.0). The constant names were also misleading: VersionNumber held the major and MajorRevisionNumber held the minor.

  2. The user agent was sent with the wrong separator. New used middleware.AddUserAgentKey, which sanitizes its whole argument and rewrites / to -.

What is changing?

  1. Replaced the four constants with a single Version = "2.2.0" in MAJOR.MINOR.PATCH form.
  2. Switched to middleware.AddUserAgentKeyValue, which sanitizes the key and value separately and joins them with /, so the separator survives.
  3. Removed releaseVersion() and userAgent(), which existed only to assemble the version from its four parts.
  4. Added secretcache/versionInfo_test.go covering the version format and the User-Agent as sent.

Related Links

  • Issue #, if available: N/A

Evidence: the SDK's rules function replaces any character outside its allowlist with -, and / is
not allowed.


Testing

How was this tested?

  1. go build ./..., go vet ./... and gofmt are clean.
  2. go test ./secretcache — 39 tests pass, coverage 97.6%. Also passes under -race.
  3. New tests confirm the User-Agent on a real request by pointing the SDK at a local endpoint, so the header is checked as sent rather than as configured. No credentials, network access or AWS account required.
  4. Each new test was verified to fail when its defect is reintroduced: reverting to AddUserAgentKey, setting Version to 2.2.0.0, and replacing the header instead of appending to it.

When testing locally, provide testing artifact(s):

  1. The captured User-Agent before and after the change:
before: aws-sdk-go-v2/1.36.2 ua/2.1 os/macos ... api/secretsmanager#1.34.19 AwsSecretCache-2.2.0 m/E
after:  aws-sdk-go-v2/1.36.2 ua/2.1 os/macos ... api/secretsmanager#1.34.19 AwsSecretCache/2.2.0 m/E

The SDK's own entries are intact in both, confirming our value is appended rather than overwriting the header.


Reviewer notes

Breaking change: this removes the exported VersionNumber, MajorRevisionNumber, MinorRevisionNumber and BugfixRevisionNumber constants. Nothing in this repository referenced them and they were not documented in the README, but they were part of the public API. Callers should use Version.

Release note: Version stays at 2.2.0 here, matching the currently published tag v2.2.0. Whoever cuts the next release should bump Version to the new tag as part of that release

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.55%. Comparing base (0f06393) to head (69faf09).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #132      +/-   ##
==========================================
- Coverage   96.59%   96.55%   -0.05%     
==========================================
  Files           7        6       -1     
  Lines         294      290       -4     
==========================================
- Hits          284      280       -4     
  Misses          8        8              
  Partials        2        2              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@simonmarty
simonmarty marked this pull request as ready for review August 4, 2026 23:42
@simonmarty
simonmarty requested a review from a team as a code owner August 4, 2026 23:42
simonmarty
simonmarty previously approved these changes Aug 4, 2026
Comment thread secretcache/versionInfo.go Outdated
The version was assembled from four separately named constants whose
names did not match their contents: VersionNumber held the major and
MajorRevisionNumber the minor. They produced a four-component string
that matched neither the released git tag nor the version published on
pkg.go.dev. Replace them with a single Version constant in
MAJOR.MINOR.PATCH form.

Also switch from AddUserAgentKey to AddUserAgentKeyValue.
AddUserAgentKey sanitizes its entire argument and rewrote the "/"
separator to "-", so requests reported "AwsSecretCache-2.2.0" rather
than "AwsSecretCache/2.2.0". AddUserAgentKeyValue sanitizes the key and
value separately and joins them afterwards, leaving the separator intact.

Add tests covering the version format and the User-Agent as sent, the
latter read from a request captured at a local endpoint so it verifies
the header on the wire rather than the configuration.

BREAKING CHANGE: removes the exported VersionNumber, MajorRevisionNumber,
MinorRevisionNumber and BugfixRevisionNumber constants. Nothing in this
repository referenced them, but they were part of the public API.
@simonmarty
simonmarty merged commit 5011c01 into master Aug 5, 2026
5 checks passed
@simonmarty
simonmarty deleted the fix_version_info branch August 5, 2026 21:22
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.

3 participants