Skip to content

client: set default user-agent based on module version#52167

Merged
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:client_ua
Mar 17, 2026
Merged

client: set default user-agent based on module version#52167
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:client_ua

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

client: set default user-agent based on module version

Before this change, the client would use Go's default (Go-http-client/1.1)
user-agent if nothing was configured; this default User-Agent is known to
be blocked by various services, so users should always opt for setting an
explicit User-Agent, but for situations where it's not set, we now set a
default based on the module version, falling back to v0.0.0+unknown when
failing;

moby-client/v0.0.0+unknown linux/arm64

- Human readable description for the release notes

client: the client now sets a default User-Agent if none was set, to prevent Go's default (`Go-http-client/1.1`) from being used.

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the 29.3.1 milestone Mar 12, 2026
@thaJeztah thaJeztah added status/2-code-review kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/changelog area/go-sdk impact/go-sdk Noteworthy (compatibility changes) in the Go SDK module/client labels Mar 12, 2026
Comment thread client/internal/mod/mod.go
@thaJeztah thaJeztah force-pushed the client_ua branch 5 times, most recently from f02e80b to a73ae09 Compare March 13, 2026 10:55
Comment thread client/internal/mod/mod.go Outdated
// The returned value is intended for display purposes (e.g., in a default
// User-Agent), not for version comparison.
//
// [module.PseudoVersionBase]: https://pkg.go.dev/golang.org/x/mod/module@PseudoVersionBase
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang! Fat-fingered typing the URL; @ -> # - I wanted to make it a versioned URL let me fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// User-Agent), not for version comparison.
//
// [module.PseudoVersionBase]: https://pkg.go.dev/golang.org/x/mod/module@PseudoVersionBase
// [mod.Version]: https://pkg.go.dev/github.com/moby/moby/[email protected]/daemon/internal/builder-next/worker/mod#Version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm wait why is it in builder-next? 🤔

Also, should we use the client or moby/moby module version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one, we want to use the client version; the goal here is that someone using the client would get a default set based on the module they use;

import "github.com/moby/moby/client"

...

client.New

For the builder-next one; I have a branch (to be updated with fixes) to move it to daemon/internal so that we can use it in other places in the daemon (e.g. to include the Moby module version in docker info or docker version; #52170

Before this change, the client would use Go's default (`Go-http-client/1.1`)
user-agent if nothing was configured; this default User-Agent is known to
be blocked by various services, so users should always opt for setting an
explicit User-Agent, but for situations where it's not set, we now set a
default based on the module version, falling back to `v0.0.0+unknown` when
failing;

    moby-client/v0.0.0+unknown linux/arm64

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member Author

Rebased; this should be good for review again

@thaJeztah thaJeztah merged commit 086a6eb into moby:master Mar 17, 2026
212 of 213 checks passed
@thaJeztah thaJeztah deleted the client_ua branch March 17, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/go-sdk impact/changelog impact/go-sdk Noteworthy (compatibility changes) in the Go SDK kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. module/client status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants