Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions internal/providers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,24 +580,30 @@ func isVertexProviderConfig(p config.RawProviderConfig) bool {
}

func validVertexProviderConfig(p config.RawProviderConfig) bool {
if !hasResolvedProviderValue(p.BaseURL) &&
(!hasResolvedProviderValue(p.VertexProject) || !hasResolvedProviderValue(p.VertexLocation)) {
if !HasResolvedProviderValue(p.BaseURL) &&
(!HasResolvedProviderValue(p.VertexProject) || !HasResolvedProviderValue(p.VertexLocation)) {
return false
}
authType := strings.ToLower(strings.TrimSpace(p.AuthType))
switch authType {
case "", "gcp_adc", "adc", "google_adc":
return true
case "gcp_service_account", "service_account":
return hasResolvedProviderValue(p.ServiceAccountFile) ||
hasResolvedProviderValue(p.ServiceAccountJSON) ||
hasResolvedProviderValue(p.ServiceAccountJSONBase64)
return HasResolvedProviderValue(p.ServiceAccountFile) ||
HasResolvedProviderValue(p.ServiceAccountJSON) ||
HasResolvedProviderValue(p.ServiceAccountJSONBase64)
default:
return false
}
}

func hasResolvedProviderValue(value string) bool {
// HasResolvedProviderValue reports whether a provider-config field carries a
// usable string value. It returns false for empty/whitespace input and false
// when the value still contains a literal `${` substring — that signals an
// unresolved YAML environment-variable placeholder such as `${OPENAI_API_KEY}`
// which the env-substitution pass failed to fill in. Provider builders use
// this to drop providers whose credentials never resolved.
func HasResolvedProviderValue(value string) bool {
value = strings.TrimSpace(value)
return value != "" && !strings.Contains(value, "${")
}
Expand Down
9 changes: 2 additions & 7 deletions internal/providers/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func (p *Provider) validateConfig(providerCfg providers.ProviderConfig) {
p.configErr = fmt.Errorf("vertex Gemini requires gcp_adc or gcp_service_account auth")
return
}
if p.backend == geminiBackendVertex && !hasResolvedProviderValue(providerCfg.BaseURL) &&
(!hasResolvedProviderValue(providerCfg.VertexProject) || !hasResolvedProviderValue(providerCfg.VertexLocation)) {
if p.backend == geminiBackendVertex && !providers.HasResolvedProviderValue(providerCfg.BaseURL) &&
(!providers.HasResolvedProviderValue(providerCfg.VertexProject) || !providers.HasResolvedProviderValue(providerCfg.VertexLocation)) {
p.configErr = fmt.Errorf("vertex Gemini requires base_url or vertex_project and vertex_location")
return
}
Expand Down Expand Up @@ -263,11 +263,6 @@ func normalizeGeminiBackend(cfg providers.ProviderConfig) string {
return geminiBackendAIStudio
}

func hasResolvedProviderValue(value string) bool {
value = strings.TrimSpace(value)
return value != "" && !strings.Contains(value, "${")
}

func normalizeGeminiAuthType(backend string, cfg providers.ProviderConfig) string {
authType := strings.ToLower(strings.TrimSpace(cfg.AuthType))
switch authType {
Expand Down
9 changes: 2 additions & 7 deletions internal/providers/vertex/vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func newProvider(providerCfg providers.ProviderConfig, opts providers.ProviderOp
}

func (p *Provider) validateConfig(providerCfg providers.ProviderConfig) {
if !hasResolvedProviderValue(providerCfg.BaseURL) &&
(!hasResolvedProviderValue(providerCfg.VertexProject) || !hasResolvedProviderValue(providerCfg.VertexLocation)) {
if !providers.HasResolvedProviderValue(providerCfg.BaseURL) &&
(!providers.HasResolvedProviderValue(providerCfg.VertexProject) || !providers.HasResolvedProviderValue(providerCfg.VertexLocation)) {
p.configErr = fmt.Errorf("vertex AI requires base_url or vertex_project and vertex_location")
return
}
Expand Down Expand Up @@ -106,11 +106,6 @@ func validAuthType(authType string) bool {
}
}

func hasResolvedProviderValue(value string) bool {
value = strings.TrimSpace(value)
return value != "" && !strings.Contains(value, "${")
}

func normalizeAuthType(providerCfg providers.ProviderConfig) string {
return googleauth.NormalizeAuthType(providerCfg.AuthType, googleauth.HasServiceAccount(buildGoogleAuthConfig(providerCfg)))
}
Expand Down
Loading