on main help sign in
Revert "refactor(tidy): remove nested if and else block"
96af782kujtimiihoxha
internal/config/config.go+9−6
@@ -546,12 +546,15 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
546 if err != nil {
546 if err != nil {
547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
548 }
548 }
549− if c.ID == string(catwalk.InferenceProviderZAI) && b.StatusCode == http.StatusUnauthorized {
549+ if c.ID == string(catwalk.InferenceProviderZAI) {
550+ if b.StatusCode == http.StatusUnauthorized {
550− // for z.ai just check if the http response is not 401
551+ // for z.ai just check if the http response is not 401
551− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
552+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
552− }
553+ }
554+ } else {
553− if b.StatusCode != http.StatusOK {
555+ if b.StatusCode != http.StatusOK {
554− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
556+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
557+ }
555 }
558 }
556 _ = b.Body.Close()
559 _ = b.Body.Close()
557 return nil
560 return nil