Resolve authentication diagnostics by provider

This commit is contained in:
2026-11-22 18:16:13 +00:00
parent adc700f96e
commit ca8cf1b827
10 changed files with 123 additions and 38 deletions

View File

@@ -11,7 +11,7 @@ import (
)
type smokeAuthenticationClient interface {
ProbeOpenRouterKey(context.Context, string, int, domain.ExecutionTarget) (llm.AuthenticationEvidence, error)
ProbeAuthentication(context.Context, string, string, int, domain.ExecutionTarget) (llm.AuthenticationEvidence, error)
}
type authenticationProbe struct{ client smokeAuthenticationClient }
@@ -30,7 +30,8 @@ func (p authenticationProbe) run(ctx context.Context, backend domain.Backend, ta
if err != nil || !outcome.supported || (outcome.applicable != nil && !*outcome.applicable) {
return outcome, err
}
result, requestErr := p.client.ProbeOpenRouterKey(ctx, target.Endpoint, target.EffectiveSettings.TimeoutSeconds, target.EffectiveSettings)
adapter := llm.AuthenticationAdapter(backend.Provider, backend.SmokeTests)
result, requestErr := p.client.ProbeAuthentication(ctx, adapter, target.Endpoint, target.EffectiveSettings.TimeoutSeconds, target.EffectiveSettings)
outcome.evidence = result.HTTP
outcome.credentialsAccepted = result.Accepted
if result.Overflow {
@@ -55,22 +56,18 @@ func (p authenticationProbe) run(ctx context.Context, backend domain.Backend, ta
}
func (p authenticationProbe) support(backend domain.Backend) (authenticationProbeOutcome, error) {
if backend.SmokeTests == nil || backend.SmokeTests.Authentication == nil {
adapter := llm.AuthenticationAdapter(backend.Provider, backend.SmokeTests)
if adapter == "" {
return authenticationProbeOutcome{reason: domain.SmokeTestReasonProbeNotConfigured}, nil
}
authentication := backend.SmokeTests.Authentication
if authentication.Kind == nil {
return authenticationProbeOutcome{}, fmt.Errorf("%w: authentication probe kind is missing", ErrInvalidRequest)
}
switch *authentication.Kind {
case "none":
if adapter == "none" {
return authenticationProbeOutcome{supported: true, applicable: boolPointer(false), reason: domain.SmokeTestReasonAuthenticationNotApplicable}, nil
case "openrouter_key":
if p.client == nil {
return authenticationProbeOutcome{reason: domain.SmokeTestReasonHTTPDiagnosticsUnavailable}, nil
}
return authenticationProbeOutcome{supported: true, applicable: boolPointer(true)}, nil
default:
return authenticationProbeOutcome{}, fmt.Errorf("%w: unsupported authentication probe kind %q", ErrInvalidRequest, *authentication.Kind)
}
if !llm.SupportedAuthenticationAdapter(adapter) {
return authenticationProbeOutcome{reason: domain.SmokeTestReasonProbeNotConfigured}, nil
}
if p.client == nil {
return authenticationProbeOutcome{reason: domain.SmokeTestReasonHTTPDiagnosticsUnavailable}, nil
}
return authenticationProbeOutcome{supported: true, applicable: boolPointer(true)}, nil
}