cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(login): prevent panic with --ignore-ssl-errors on subsequent runs

Open conradj3 opened this issue 2 months ago • 1 comments

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:

  1. First login: HTTP client uses direct *http.Transport
  2. Subsequent logins: HTTP client uses *SpinnerRoundTripper wrapping *http.Transport (for interactive spinner display)
  3. The crash: Code assumed transport would always be *http.Transport and performed unsafe type assertion

Solution

Replaced the unsafe type assertion with proper type switching to handle multiple transport scenarios:

  • ✅ Direct *http.Transport (first login)
  • *SpinnerRoundTripper wrapping *http.Transport (subsequent logins)
  • ✅ Fallback for any other transport types

Changes

  • Modified SSL ignore logic in pkg/cmd/login/login.go to 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.

conradj3 avatar Oct 04 '25 23:10 conradj3

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 04 '25 23:10 CLAassistant