Skip to content

login: warn when the server address contains an explicit scheme - #5169

Closed
locker95 wants to merge 1 commit into
containerd:mainfrom
locker95:login-warn-explicit-scheme
Closed

login: warn when the server address contains an explicit scheme#5169
locker95 wants to merge 1 commit into
containerd:mainfrom
locker95:login-warn-explicit-scheme

Conversation

@locker95

@locker95 locker95 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #3052.

As noted by @fahedouch in the issue ("It looks like a bug. It is not the intended behavior."), nerdctl login silently drops an explicit scheme from the server address. Following the direction suggested by @apostasie, this change warns the user that this syntax is only supported as a convenience and that the scheme is ignored; when http:// was requested, the warning additionally points at the global --insecure-registry flag. The warning is emitted only from the login code path — dockerconfigresolver.Parse is untouched, so credential lookup during pull/push stays silent.

Testing: a platform-independent unit test covers the new detection helper (verified locally on macOS); TestLoginAgainstVariants now also asserts the warning on stderr for the scheme variants. I could only compile-verify the Linux integration test locally (GOOS=linux go build ./... / go vet / go test -c), so I am relying on CI to exercise it.

This patch was developed with the assistance of an AI tool (Claude); I have reviewed and tested the change and take responsibility for it.

`nerdctl login` accepts a server address with an explicit scheme (e.g.
`https://index.docker.io/v1/`) only as a convenience: the scheme is
silently disregarded and connections are made over https regardless,
which is surprising when the user asked for `http://`. Warn the user
that the scheme is ignored, and point at the global --insecure-registry
flag when plain http was requested. Credential lookup paths reusing
dockerconfigresolver.Parse (pull/push) are intentionally left silent.

Fixes containerd#3052

Signed-off-by: Dean Chen <862469039@qq.com>
@AkihiroSuda AkihiroSuda added this to the v2.4.0 milestone Sep 8, 2026
@AkihiroSuda

Copy link
Copy Markdown
Member

I could only compile-verify the Linux integration test locally (GOOS=linux go build ./... / go vet / go test -c), so I am relying on CI to exercise it.

This patch was developed with the assistance of an AI tool (Claude); I have reviewed and tested the change and take responsibility for it.

Please responsibly test your PR with actual registries, by running nerdctl login manually.

@AkihiroSuda AkihiroSuda removed this from the v2.4.0 milestone Sep 8, 2026
@AkihiroSuda AkihiroSuda added the area/login authentification/ login label Sep 8, 2026
Comment thread pkg/cmd/login/login.go
if !found || (sch != "http" && sch != "https") {
return ""
}
warning := fmt.Sprintf("The %s:// scheme in the provided server address %q is accepted only as a convenience, "+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does docker login have such a message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no — docker login just strips the scheme in ConvertToHostname and stays quiet. I can drop the warning if you would rather match that.

@locker95

locker95 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

on testing: I do not have a registry handy here. the unit tests pass; the linux integration job already logs in with the http(s):// variants.

on the warning: docker login does not print one (ConvertToHostname just strips the scheme). happy to drop it if you would rather keep parity.

@AkihiroSuda

Copy link
Copy Markdown
Member

Testing: a platform-independent unit test covers the new detection helper (verified locally on macOS); TestLoginAgainstVariants now also asserts the warning on stderr for the scheme variants. I could only compile-verify the Linux integration test locally (GOOS=linux go build ./... / go vet / go test -c), so I am relying on CI to exercise it.

on testing: I do not have a registry handy here. the unit tests pass; the linux integration job already logs in with the http(s):// variants.

A contributor has to learn how to test their PR ahead of the submission.

@AkihiroSuda AkihiroSuda closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/login authentification/ login

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nerdctl login should warn about passing along an explicit scheme

2 participants