File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,21 +84,18 @@ func GetActiveProviderConfig() (*ProviderConfig, error) {
8484
8585// GetAPIKey returns the API key for the active provider.
8686func GetAPIKey () (string , error ) {
87- providerConfig , err := GetActiveProviderConfig ()
88- if err != nil {
89- // If config for the provider doesn't exist, that's an issue.
90- // However, for copilot, we can try to load the token directly.
91- if cfg .ActiveProvider == "copilot" {
92- return LoadGitHubToken ()
93- }
94- return "" , err
87+ if cfg == nil {
88+ InitConfig ()
9589 }
96-
97- // Special handling for copilot to always prefer a freshly loaded token.
9890 if cfg .ActiveProvider == "copilot" {
9991 return LoadGitHubToken ()
10092 }
10193
94+ providerConfig , err := GetActiveProviderConfig ()
95+ if err != nil {
96+ return "" , err
97+ }
98+
10299 if providerConfig .APIKey == "" {
103100 return "" , fmt .Errorf ("API key for provider '%s' is not set" , cfg .ActiveProvider )
104101 }
You can’t perform that action at this time.
0 commit comments