Skip to content

fix: set zarf version in the user-agent field of oci-client - #5227

Closed
samayer12 wants to merge 3 commits into
zarf-dev:mainfrom
samayer12:sammayer/user-agent-fix
Closed

fix: set zarf version in the user-agent field of oci-client#5227
samayer12 wants to merge 3 commits into
zarf-dev:mainfrom
samayer12:sammayer/user-agent-fix

Conversation

@samayer12

@samayer12 samayer12 commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Fix Zarf OCI remote setup so registry requests include the expected User-Agent: zarf/<CLI version> header.

zoci.NewRemote() previously passed the user-agent as a modifier into oci.NewOrasRemote(), but the underlying OCI wrapper replaces the ORAS auth client during repository setup. That replacement dropped the configured header, so UDS Registry observed Go's default Go-http-client/2.0 instead of the Zarf version.

This change applies the Zarf user-agent after oci.NewOrasRemote() returns, ensuring it is set on the final client used for publish, pull, copy, and related OCI operations.

See https://github.com/defenseunicorns/uds-registry/pull/3206 for the original PR that discovered this bug.

Fixes #5226

Changes

  • Apply oci.WithUserAgent("zarf/" + config.CLIVersion) after oci.NewOrasRemote() returns in zoci.NewRemote().
  • Add a regression test that verifies the final ORAS auth client has User-Agent: zarf/<CLI version>.

Validation

go test ./src/pkg/zoci -run TestNewRemoteSetsZarfUserAgentOnFinalClient -count=1
go test ./src/pkg/zoci -count=1

Post-fix Evidence

Successful post-fix metric showing the client family and version were detected by UDS Registry metrics:

{
  "metric": {
    "client_family": "zarf",
    "client_version": "0.82.x",
    "result": "accepted"
  },
  "value": [
    1786721539.717,
    "1"
  ]
}

@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit bf54317
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6a7f580c79bd2d0008098b4f

@samayer12
samayer12 marked this pull request as ready for review August 14, 2026 16:04
@samayer12
samayer12 requested review from a team as code owners August 14, 2026 16:04
Signed-off-by: Sam Mayer <samayer12@gmail.com>
Signed-off-by: Sam Mayer <samayer12@gmail.com>
@samayer12
samayer12 force-pushed the sammayer/user-agent-fix branch from c1931a4 to 7dfc2f7 Compare August 14, 2026 16:09
@brandtkeller

Copy link
Copy Markdown
Member

Hmm.. Something looks funky on the netlify actions. @samayer12 could you merge the latest changes from main into this branch?

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/pkg/zoci/common.go 75.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@samayer12

Copy link
Copy Markdown
Author

@brandtkeller updated from main, looks like that solved the netlify issue

@AustinAbro321

Copy link
Copy Markdown
Member

@samayer12 Thanks for the find! It seems this is a bug in defenseunicorns/pkg/oci. Could you instead add this fix there? I wouldn't be surprised if this bug was also affecting uds-cli.

@samayer12

Copy link
Copy Markdown
Author

@AustinAbro321 sure thing, I'll close this PR and open one over there instead

@samayer12 samayer12 closed this Aug 14, 2026
@github-project-automation github-project-automation Bot moved this to Done in Zarf Aug 14, 2026
@AustinAbro321

Copy link
Copy Markdown
Member

@samayer12 Wait! I think our friend @Racer159 is already fixing this in defenseunicorns/pkg#202, which I'm reviewing now. Awesome timing hahaha

@brandtkeller

Copy link
Copy Markdown
Member

@samayer12 please review defenseunicorns/pkg#202 first as I believe it fixes this issue?

@AustinAbro321

Copy link
Copy Markdown
Member

Another timing coincidence @brandtkeller !!

@samayer12

Copy link
Copy Markdown
Author

Yep, this looks great. Specifically, this test case on the user-agent covers what we're after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

user-agent string is not set to zarf/x.y.z in HTTP requests

3 participants