Fix kit login failure when trace logging is enabled#1070
Fix kit login failure when trace logging is enabled#1070amisevsk merged 2 commits intokitops-ml:mainfrom
kit login failure when trace logging is enabled#1070Conversation
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
|
tested it on local machine
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
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 |
There was a problem hiding this comment.
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
LoggingTransportthat wrapshttp.RoundTripperinstead of wrapping the entire client - Modified
WrapClient()to detect*auth.Clientinstances 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.
amisevsk
left a comment
There was a problem hiding this comment.
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).
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
amisevsk
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks @akagami-harsh
Description
pkg/output/client.goto use aLoggingTransportinstead of wrapping the entire client struct. This ensures the client remains satisfied as an*auth.Clientfor the oras library while still logging requests, because Theoras-golibrary'sloginfunction 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 customLoggingClientstruct to capture request metrics, which caused this type assertion to fail.Linked issues
kit loginwith trace debugging enabled #807 a bug where runningkit loginwith trace logging enabled (e.g.,kit login -vv) would fail with the errorclient type not supportedAI-Assisted Code