cli
cli copied to clipboard
fix(login): prevent panic with --ignore-ssl-errors on subsequent runs
Problem
When running octopus login --ignore-ssl-errors after an initial successful login, the CLI crashes with a panic:
panic: interface conversion: http.RoundTripper is *apiclient.SpinnerRoundTripper, not *http.Transport
This occurs because:
- First login: HTTP client uses direct
*http.Transport - Subsequent logins: HTTP client uses
*SpinnerRoundTripperwrapping*http.Transport(for interactive spinner display) - The crash: Code assumed transport would always be
*http.Transportand performed unsafe type assertion
Solution
Replaced the unsafe type assertion with proper type switching to handle multiple transport scenarios:
- ✅ Direct
*http.Transport(first login) - ✅
*SpinnerRoundTripperwrapping*http.Transport(subsequent logins) - ✅ Fallback for any other transport types
Changes
- Modified SSL ignore logic in
pkg/cmd/login/login.goto use type switching - Added comprehensive test coverage in
pkg/cmd/login/login_ssl_test.go - All existing tests continue to pass
Testing
- [x] Unit tests for all transport scenarios
- [x] All existing login tests pass
- [x] CLI builds and runs successfully
Related Issues
Fixes the panic described in the original issue where users couldn't run octopus login --ignore-ssl-errors multiple times.