Bound authentication response recognition

This commit is contained in:
2026-11-05 13:49:51 +00:00
parent 1c075bd510
commit 7be677c80b
6 changed files with 93 additions and 7 deletions

View File

@@ -17,6 +17,8 @@ type authenticationProbe struct {
client smokeHTTPGetter
}
const maxAuthenticationResponseBytes = 1 << 20
type authenticationProbeOutcome struct {
supported bool
applicable *bool
@@ -104,7 +106,17 @@ func (p authenticationProbe) runOpenRouterKey(
outcome.failure = domain.ExecutionFailureMalformedResponse
return outcome, nil
}
recognized, bodyErr := recognizedOpenRouterKeyResponse(response.Body)
contents, bodyErr := io.ReadAll(io.LimitReader(response.Body, maxAuthenticationResponseBytes+1))
if len(contents) > maxAuthenticationResponseBytes {
outcome.reason = domain.SmokeTestReasonAuthenticationResponseLimitExceeded
outcome.failure = domain.ExecutionFailureOther
return outcome, nil
}
if bodyErr != nil {
outcome.failure = httpProbeFailure(ctx, bodyErr)
return outcome, nil
}
recognized, bodyErr := recognizedOpenRouterKeyResponse(bytes.NewReader(contents))
if bodyErr != nil {
outcome.failure = httpProbeFailure(ctx, bodyErr)
return outcome, nil