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

Method markKeyOnError

aibridge/intercept/responses/base.go:176–188  ·  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

174// code. Returns true if the status was a key-specific failover
175// trigger so callers can retry with the next key.
176func (i *responsesInterceptionBase) markKeyOnError(ctx context.Context, key *keypool.Key, err error) bool {
177 if i.cfg.KeyPool == nil {
178 return false
179 }
180 var apiErr *openai.Error
181 if !errors.As(err, &apiErr) {
182 return false
183 }
184 return keypool.MarkKeyOnStatus(
185 ctx, key, apiErr.Response,
186 i.logger, i.providerName,
187 )
188}
189
190// sendCustomErr sends custom responses.Error error to the client
191// it should only be called before any data is sent back to the client

Callers 3

TestMarkKeyOnErrorFunction · 0.95
ProcessRequestMethod · 0.45

Calls 2

MarkKeyOnStatusFunction · 0.92
AsMethod · 0.80

Tested by 1

TestMarkKeyOnErrorFunction · 0.76