MCPcopy Index your code
hub / github.com/coder/coder / markKeyOnError

Method markKeyOnError

aibridge/intercept/chatcompletions/base.go:221–233  ·  view source on GitHub ↗

For centralized requests, markKeyOnError extracts an OpenAI SDK error from err and marks the key based on its status code. Returns true if the status was a key-specific failover trigger so callers can retry with the next key.

(ctx context.Context, key *keypool.Key, err error)

Source from the content-addressed store, hash-verified

219// code. Returns true if the status was a key-specific failover
220// trigger so callers can retry with the next key.
221func (i *interceptionBase) markKeyOnError(ctx context.Context, key *keypool.Key, err error) bool {
222 if i.cfg.KeyPool == nil {
223 return false
224 }
225 var apiErr *openai.Error
226 if !errors.As(err, &apiErr) {
227 return false
228 }
229 return keypool.MarkKeyOnStatus(
230 ctx, key, apiErr.Response,
231 i.logger, i.providerName,
232 )
233}
234
235func (i *interceptionBase) hasInjectableTools() bool {
236 return i.mcpProxy != nil && len(i.mcpProxy.ListTools()) > 0

Callers 3

TestMarkKeyOnErrorFunction · 0.95
ProcessRequestMethod · 0.45

Calls 2

MarkKeyOnStatusFunction · 0.92
AsMethod · 0.80

Tested by 1

TestMarkKeyOnErrorFunction · 0.76