fix: allow Onboard UI to overwrite existing provider apiKey/baseUrl#38674
fix: allow Onboard UI to overwrite existing provider apiKey/baseUrl#38674Fa1eon wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Previously, mergeWithExistingProviderSecrets() always preserved existing apiKey and baseUrl values from models.json, preventing users from updating these values through the Onboard UI. Now, the function only preserves existing secrets when the new entry doesn't provide them. This allows users to correct configuration mistakes and update provider settings via the UI. Fixes openclaw#38657
Greptile SummaryThis PR fixes a bug in The fix adds Critical issue: The existing test at line 210 ( Confidence Score: 2/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f70d9ff7d2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (typeof existing.apiKey === "string" && existing.apiKey && !newEntry.apiKey) { | ||
| preserved.apiKey = existing.apiKey; | ||
| } | ||
| if (typeof existing.baseUrl === "string" && existing.baseUrl) { | ||
| if (typeof existing.baseUrl === "string" && existing.baseUrl && !newEntry.baseUrl) { | ||
| preserved.baseUrl = existing.baseUrl; |
There was a problem hiding this comment.
Keep merge mode from clobbering existing provider secrets
This conditional now replaces non-empty models.json apiKey/baseUrl values whenever the new provider entry has non-empty fields, which regresses merge-mode semantics that currently preserve agent-local credentials (src/config/schema.help.ts:691 and src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts:210). Since models.mode defaults to "merge", ensureOpenClawModelsJson will now silently overwrite per-agent secrets/endpoints on normal refreshes, not just in the onboarding path this fix is targeting.
Useful? React with 👍 / 👎.
Update test 'preserves non-empty agent apiKey/baseUrl for matching providers in merge mode' to expect config values to take precedence over agent values. This aligns the test with the fix in mergeWithExistingProviderSecrets() which now allows config-provided apiKey/baseUrl to overwrite existing agent values. Related to openclaw#38657
Previously,
mergeWithExistingProviderSecrets()always preserved existingapiKeyandbaseUrlvalues frommodels.json, preventing users from updating these values through the Onboard UI.Now, the function only preserves existing secrets when the new entry doesn't provide them. This allows users to correct configuration mistakes and update provider settings via the UI.
Fixes #38657
Summary
&& !newEntry.apiKeyand&& !newEntry.baseUrl) to only preserve existing secrets when the new config doesn't provide them.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Users can now update provider apiKey and baseUrl values through the Onboard UI. Previously, these values were silently ignored if they already existed in models.json.
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
The provider configuration should be updated with the new apiKey "NEW_KEY".
Actual
Before fix: The old apiKey "OLD_KEY" remains in models.json, ignoring the UI update.
After fix: The new apiKey "NEW_KEY" correctly overwrites the old value.
Evidence
src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.tsHuman Verification (required)
Verified scenarios:
Edge cases checked:
What you did not verify:
models.modeset to values other than "merge"Compatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations