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

Function validateLegacyAIBridgeConfig

cli/server.go:3276–3294  ·  view source on GitHub ↗

validateLegacyAIBridgeConfig enforces invariants on the legacy single-provider env vars (CODER_AIBRIDGE_ANTHROPIC_KEY, CODER_AIBRIDGE_BEDROCK_*) that the indexed validator above can't catch because legacy fields live outside cfg.Providers.

(cfg codersdk.AIBridgeConfig)

Source from the content-addressed store, hash-verified

3274// CODER_AIBRIDGE_BEDROCK_*) that the indexed validator above can't
3275// catch because legacy fields live outside cfg.Providers.
3276func validateLegacyAIBridgeConfig(cfg codersdk.AIBridgeConfig) error {
3277 // An Anthropic provider authenticates either via a bearer token
3278 // or via Bedrock, not both. Fields without serpent-level
3279 // defaults (region, base URL, credentials) reliably indicate
3280 // operator intent; Model and SmallFastModel are excluded because
3281 // they have defaults.
3282 settings := codersdk.NewAIProviderBedrockSettings(
3283 cfg.LegacyBedrock.Region.String(),
3284 cfg.LegacyBedrock.AccessKey.String(),
3285 cfg.LegacyBedrock.AccessKeySecret.String(),
3286 cfg.LegacyBedrock.Model.String(),
3287 cfg.LegacyBedrock.SmallFastModel.String(),
3288 )
3289 hasBedrock := codersdk.IsBedrockConfigured(cfg.LegacyBedrock.BaseURL.String(), settings)
3290 if cfg.LegacyAnthropic.Key.String() != "" && hasBedrock {
3291 return xerrors.New("CODER_AIBRIDGE_ANTHROPIC_KEY and CODER_AIBRIDGE_BEDROCK_* are mutually exclusive")
3292 }
3293 return nil
3294}
3295
3296// maxKeysPerProvider is the maximum number of keys allowed per
3297// provider. This bounds the failover pool size and keeps the

Callers 2

ServerMethod · 0.85

Calls 4

IsBedrockConfiguredFunction · 0.92
NewMethod · 0.65
StringMethod · 0.45

Tested by 1