refactor(controller): update modelconfig REST API#1717
Merged
EItanya merged 4 commits intokagent-dev:mainfrom Apr 20, 2026
Merged
refactor(controller): update modelconfig REST API#1717EItanya merged 4 commits intokagent-dev:mainfrom
EItanya merged 4 commits intokagent-dev:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the ModelConfig HTTP REST handlers/types to align the API payloads/responses with newer ModelConfig CRD fields and supported providers.
Changes:
- Extend ModelConfig list/get/update responses to include
apiKeyPassthrough,defaultHeaders, and additional provider params (VertexAI + Bedrock). - Update create/update request handling to accept
tls,defaultHeaders, secret references, and Bedrock params. - Adjust secret-creation/update logic to prefer explicit secret references over inline API keys.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| go/core/internal/httpserver/handlers/modelconfig.go | Adds Bedrock/VertexAI param flattening; surfaces new CRD fields in responses; extends create/update to accept TLS/default headers/secret refs. |
| go/api/httpapi/types.go | Updates REST API request/response structs with new fields (TLS/default headers/secret refs/Bedrock params; response adds apiKeyPassthrough). |
Comments suppressed due to low confidence (2)
go/core/internal/httpserver/handlers/modelconfig.go:491
shouldUpdateSecretcan be true whilemodelConfig.Spec.APIKeySecretKeyis empty (e.g., existing ModelConfigs without a secret key, or Bedrock where the key is optional). This will callcreateOrUpdateSecretWithOwnerReferencewith a map containing an empty data key, which Kubernetes will reject. Before updating, ensure a non-empty secret key is set (and setAPIKeySecret/APIKeySecretKeydefaults when using inlineapiKey), or return a 400.
// Update inline API key secret only when not using an explicit secret ref
shouldUpdateSecret := req.APIKeySecret == "" && req.APIKey != nil && *req.APIKey != "" && modelConfig.Spec.Provider != v1alpha2.ModelProviderOllama
if shouldUpdateSecret {
log.V(1).Info("Updating API key secret")
err := createOrUpdateSecretWithOwnerReference(
r.Context(),
h.KubeClient,
map[string]string{modelConfig.Spec.APIKeySecretKey: *req.APIKey},
modelConfig,
go/core/internal/httpserver/handlers/modelconfig.go:274
- The inline
apiKeyfallback will also run for the Bedrock provider, creating/updating a Secret entry likeBEDROCK_API_KEY. Bedrock auth in the translator expects AWS credential keys (e.g.,AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYorAWS_BEARER_TOKEN_BEDROCK), so an inline API key flow here will create a non-functional (and potentially misleading) ModelConfig. Consider disallowing inlineapiKeyfor Bedrock (requireapiKeySecret), or add explicit Bedrock credential fields.
} else if providerTypeEnum != v1alpha2.ModelProviderOllama && req.APIKey != "" {
secretName := modelConfigRef.Name
secretKey := fmt.Sprintf("%s_API_KEY", strings.ToUpper(req.Provider.Type))
modelConfigSpec.APIKeySecret = secretName
modelConfigSpec.APIKeySecretKey = secretKey
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
8acd35e to
a9b6570
Compare
EItanya
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.