Skip to content

cli/command/registry: remove all uses of response message - #6436

Draft
thaJeztah wants to merge 2 commits into
docker:masterfrom
thaJeztah:login_message_step2
Draft

cli/command/registry: remove all uses of response message#6436
thaJeztah wants to merge 2 commits into
docker:masterfrom
thaJeztah:login_message_step2

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

The message returned by the API is a hardcoded message; the only real information currently returned by the API is whether or not the auth was successul;
https://github.com/moby/moby/blob/v2.0.0-beta.0/daemon/server/router/system/system_routes.go#L408-L421

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

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

@thaJeztahthaJeztah added this to the 29.0.0 milestone Sep 8, 2025
@codecov-commenter

codecov-commenter commented Sep 8, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.90476% with 8 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
cli/command/registry/login.go61.90%8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Flaky test, or did break something?

67.19 === Failed
67.19 === FAIL: cli/command/registry TestLoginWithCredStoreCreds (0.00s)
67.19 login_test.go:80: assertion failed: expected an error, got nil
67.19 67.19 === FAIL: cli/command/registry TestRunLogin/expired_auth_from_store (0.00s)
67.19 login_test.go:309: assertion failed: expected an error, got nil
67.19 67.19 === FAIL: cli/command/registry TestRunLogin (0.01s)

if err := storeCredentials(dockerCLI.ConfigFile(), authConfig); err != nil {
return "", err
}

return response.Status, err
return storeCredentials(dockerCLI.ConfigFile(), authConfig)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Ah! The existing code shadowed the error; so this function would return when failing to store the credentials, but the error returned is the error from earlier?? return response.Status, err returns the err from response, err := dockerCLI.Client().RegistryLogin(ctx, authConfig), but even on failure, it would still try to store the credentials 🤔

I suspect that was a bug!

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I think this may have been introduced in 6e4818e

Before that patch, loginWithCredStoreCreds would only try to login, but did not handle saving credentials.

funcloginWithCredStoreCreds(ctx context.Context, dockerCli command.Cli, authConfig*registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
fmt.Fprintf(dockerCli.Out(), "Authenticating with existing credentials...\n")
cliClient:=dockerCli.Client()
response, err:=cliClient.RegistryLogin(ctx, *authConfig)
iferr!=nil {
iferrdefs.IsUnauthorized(err) {
fmt.Fprintf(dockerCli.Err(), "Stored credentials invalid or expired\n")
} else {
fmt.Fprintf(dockerCli.Err(), "Login did not succeed, error: %s\n", err)
}
}
returnresponse, err
}

So question is; was it intentional to save credentials even if they were invalid or expired? Or was the intent perhaps to remove / reset those credentials so that they wouldn't be used again?

iferr:=storeCredentials(dockerCLI.ConfigFile(), authConfig); err!=nil {
return"", err
}

@thaJeztah
thaJeztah marked this pull request as draft September 8, 2025 13:24
@thaJeztahthaJeztah modified the milestones: 29.0.0, 29.2.0Jan 13, 2026
The message returned by the API is a hardcoded message; the only real
information currently returned by the API is whether or not the auth
was successul;
https://github.com/moby/moby/blob/v2.0.0-beta.0/daemon/server/router/system/system_routes.go#L408-L421
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztahthaJeztah modified the milestones: 29.2.0, 29.2.1, 29.3.0Jan 26, 2026
@thaJeztahthaJeztah modified the milestones: 29.3.0, 29.3.1Mar 4, 2026
@thaJeztahthaJeztah modified the milestones: 29.4.0, 29.4.1Apr 3, 2026
@thaJeztahthaJeztah modified the milestones: 29.4.1, 29.5.0Apr 20, 2026
@thaJeztahthaJeztah modified the milestones: 29.5.0, 29.6.0May 7, 2026
@thaJeztahthaJeztah modified the milestones: 29.6.0, 29.6.1Jun 12, 2026
@vvolandvvoland removed this from the 29.6.1 milestone Jun 30, 2026
@vvolandvvoland added this to the 29.7.0 milestone Jun 30, 2026
@vvolandvvoland modified the milestones: 29.7.0, 29.8.0Jul 30, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/authenticationkind/refactorPR's that refactor, or clean-up codestatus/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@thaJeztah@codecov-commenter@vvoland