Skip to content

Fix kit login failure when trace logging is enabled#1070

Merged
amisevsk merged 2 commits intokitops-ml:mainfrom
akagami-harsh:fix-login-issue
Jan 29, 2026
Merged

Fix kit login failure when trace logging is enabled#1070
amisevsk merged 2 commits intokitops-ml:mainfrom
akagami-harsh:fix-login-issue

Conversation

@akagami-harsh
Copy link
Copy Markdown
Contributor

Description

  • Modified pkg/output/client.go to use a LoggingTransport instead of wrapping the entire client struct. This ensures the client remains satisfied as an *auth.Client for the oras library while still logging requests, because The oras-go library's login function performs a strict type assertion on the registry client, requiring it to be of type *auth.Client. Previously, our trace logging mechanism wrapped this client in a custom LoggingClient struct to capture request metrics, which caused this type assertion to fail.

Linked issues

AI-Assisted Code

  • This PR contains AI-generated code that I have reviewed and tested
  • I take full responsibility for all code in this PR, regardless of how it was created

Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
@akagami-harsh
Copy link
Copy Markdown
Contributor Author

tested it on local machine

  • Before
harshvir@msi:~/kitops$ go run . login -vv localhost:5000
[DEBUG] Using default config directory: /home/harshvir/.local/share/kitops
Username: test
Password: 
[ERROR] Client type not supported
exit status 1
  • After
harshvir@msi:~/kitops$ git checkout fix-login-issue 
Switched to branch 'fix-login-issue'
harshvir@msi:~/kitops$ go run . login -vv localhost:5000
[DEBUG] Using default config directory: /home/harshvir/.local/share/kitops
Username: test
Password: 
[ERROR] Failed to validate the credentials for localhost:5000: Get "https://localhost:5000/v2/": dial tcp 127.0.0.1:5000: connect: connection refused
exit status 1

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where kit login -vv (with trace logging enabled) fails with "client type not supported" error. The issue occurs because the oras-go library's login function performs a strict type assertion requiring *auth.Client, but the previous logging implementation wrapped the client in a custom LoggingClient struct, breaking this type assertion.

Changes:

  • Introduced a new LoggingTransport that wraps http.RoundTripper instead of wrapping the entire client
  • Modified WrapClient() to detect *auth.Client instances and wrap their transport layer instead of wrapping the client itself
  • Refactored the early return logic for improved readability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/output/client.go
Comment thread pkg/output/client.go Outdated
Comment thread pkg/output/client.go Outdated
Copy link
Copy Markdown
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

Good idea @akagami-harsh, this is a nice solution 👍

I think we can go simpler on the implementation and drop wrapping clients entirely; whoever creates a client can just wrap their transport as necessary instead of wrapping the client. This avoids the need to do a type assertion and handle specifically authClients (since we're taking in a remote.Client interface but overriding an implementation detail within that interface).

Comment thread pkg/output/client.go
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Copy link
Copy Markdown
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @akagami-harsh

@amisevsk amisevsk merged commit aba2627 into kitops-ml:main Jan 29, 2026
7 checks passed
@akagami-harsh akagami-harsh deleted the fix-login-issue branch January 30, 2026 13:32
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.

Can't use kit login with trace debugging enabled

3 participants