fix(vscode): use stored API key for model fetches when editing a custom provider - #11121
Merged
chrarnoldus merged 2 commits intoJun 15, 2026
Conversation
…om provider Keys are stripped from provider payloads before they reach the webview, so the model-fetch request for an existing provider always went out unauthenticated and gated endpoints returned 401. Retain providerID->key extension-side in fetchProviderData, send providerID from the dialog when the key field is untouched, and resolve the stored key in the fetch handler — only when the requested URL matches the provider's configured baseURL, so a stored secret can never be redirected to a different host. Addresses the API-key half of Kilo-Org#10139.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The implementation is well-designed and secure. Keys stay on the extension side end-to-end, the URL-match guard in Files Reviewed (5 files)
Fix these issues in Kilo Cloud Reviewed by claude-4.6-sonnet-20260217 · 973,218 tokens Review guidance: REVIEW.md from base branch |
chrarnoldus
approved these changes
Jun 12, 2026
NJ-2020
pushed a commit
to NJ-2020/kilocode
that referenced
this pull request
Jul 4, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…r-fetch-uses-stored-key-10139 fix(vscode): use stored API key for model fetches when editing a custom provider
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.
Issue
Addresses the API-key half of #10139 (trace in this comment). Not marked
Fixesbecause the model-list half is in #10195, and a masked-display UX suggestion from the thread remains open.Context
When editing an existing custom provider, the model fetch never used the stored API key, so gated endpoints returned 401 and the model list could not be refreshed without retyping the key. The webview cannot fix this alone:
fetchProviderDatastripskeyfrom provider payloads before they reach it (intentionally — the secret should not cross into the webview), the dialog'sfetchKeysignal initializes empty, and thefetchCustomProviderModelsmessage had no way to reference the stored credential. Confirmed by @weissfl on the issue thread.Implementation
The key stays on the extension side end to end:
fetchProviderDataalready seesraw.keyat the point where it strips it; it now retains aproviderID → { key, baseURL }map alongsideauthStates. Only providers with a configuredoptions.baseURLare retained.FetchCustomProviderModelsMessagegains an optionalproviderID. The dialog sends it only when the key field is untouched — anything typed (a key or{env:VAR}syntax) takes precedence, preserving current behavior.handleFetchCustomProviderModelsresolves the stored key via a new pureresolveStoredKeyhelper, which applies it only when the requested URL matches the provider's configured baseURL (trailing slashes normalized). A stored secret can therefore never be redirected to a different host — if the user edits the URL field, the fetch goes out keyless exactly as before.Note this also covers the empty-field symptom from the thread: the fetch now authenticates through the extension-side map regardless of whether the webview's
authStatessnapshot resolved in time, so the field showing empty instead of********no longer breaks fetching. Making the masked display itself reliable is a separate, smaller change I'm happy to follow up on.Screenshots / Video
N/A — no visual change; the dialog renders identically.
How to Test
Manual/local verification
bun test tests/unit/provider-actions-save.test.tsinpackages/kilo-vscode— 21 pass (5 new: stored-key retention infetchProviderData, URL match, trailing-slash tolerance, foreign-host refusal, unknown-id refusal). Executed by the agent.bun test tests/unit/run compared against a stashed baseline: identical pre-existing failures (unrelated, missing workspace links in my environment), zero regressions from this diff. Executed by the agent.Reviewer test steps
@weissfl offered to test on the issue thread — tagging as promised.
Blocked checks and substitute verification
bun run typecheckcould not complete cleanly in my environment because workspace packages (@kilocode/kilo-gateway,@kilocode/kilo-uitypes, etc.) are not linked; substitute verification was scopedtsc --noEmitruns on both the extension and webview projects with and without this diff — identical error counts (all pre-existing unresolved-module noise), zero errors introduced in the five changed files.Checklist
Get in Touch
I'm the agent that traced this on the issue thread; fastest way to reach me is a comment here or on #10139.