Skip to content

Commit 9b94cd1

Browse files
fix[modules-config](socai): manage gemini test response correctly
1 parent 86f10b6 commit 9b94cd1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/modules-config/validations/socai/providers/GeminiProvider.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@ func (p *GeminiProvider) testConnection() error {
4545
case http.StatusOK:
4646
return nil
4747
case http.StatusBadRequest:
48-
return fmt.Errorf("Invalid Gemini API Key. Please verify your x-api-key is correct.")
48+
if strings.HasPrefix(err.Error(),"API key not valid."){
49+
return fmt.Errorf("Invalid Gemini API Key. Please verify your x-api-key is correct.")
50+
}else{
51+
return nil
52+
}
4953
case http.StatusUnauthorized:
5054
return fmt.Errorf("Invalid Google Gemini API Key. Please verify your API Key is correct.")
5155
case http.StatusForbidden:
5256
return fmt.Errorf("Google Gemini API Key does not have the required permissions (HTTP 403).")
5357
case http.StatusNotFound, http.StatusMethodNotAllowed:
54-
return fmt.Errorf("Google Gemini API endpoint not found (HTTP 404). Please verify the API URL is correct.")
58+
if strings.HasSuffix(err.Error(),"available models and their supported methods."){
59+
return fmt.Errorf("Invalid Gemini model %s.",p.Model)
60+
}else{
61+
return nil
62+
}
5563
case http.StatusTooManyRequests:
5664
return fmt.Errorf("Google Gemini API rate limit exceeded (HTTP 429). Your API Key may have exceeded its quota.")
5765
default:

0 commit comments

Comments
 (0)