Repository navigation
fix: normalize provider keys during model config merge - #95722
Conversation
0fa59d9 to
8e497a5
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 16, 2026, 3:43 AM ET / 07:43 UTC. Summary PR surface: Source +27, Tests +240. Total +267 across 5 files. Reproducibility: yes. A high-confidence source and planner path uses Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep one shared provider-key normalizer at all generated-model merge and secret-marker boundaries, preserve the maintainer-defined canonical-spelling precedence, and land only after rebasing and clearing the exact-head failing shard without weakening the focused collision and secret-leak regressions. Do we have a high-confidence way to reproduce the issue? Yes. A high-confidence source and planner path uses Is this the best way to solve the issue? Yes. Sharing the established provider-id normalizer across all relevant map boundaries is narrower and safer than adding case-specific fallbacks, and the latest maintainer-authored commit explicitly defines the ambiguous collision precedence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 138178620d4d. Label changesLabel justifications:
Evidence reviewedPR surface: Source +27, Tests +240. Total +267 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (3 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
@clawsweeper re-review |
99b3503 to
5c5c9a5
Compare
…rkers Make enforceSourceManagedProviderSecrets canonicalize provider keys with normalizeProviderId so mixed-case (e.g. "OpenAI") source config still matches the canonical "openai" generated provider. Without this, the trim-only source lookup misses, the source SecretRef marker is never reapplied, and resolved runtime secret values leak into generated models.json. Adds plan-level regressions in models-config.runtime-source-snapshot.test.ts covering mixed-case apiKey and header source configs.
oxlint(no-array-sort) flagged the new test assertions for using .sort() on Object.keys(...). Switch to .toSorted() to keep the check-lint shard green.
5c5c9a5 to
155c3f9
Compare
|
Merged via squash.
|
* fix: normalize provider keys during model config merge * fix: normalize source-managed provider keys when reapplying secret markers Make enforceSourceManagedProviderSecrets canonicalize provider keys with normalizeProviderId so mixed-case (e.g. "OpenAI") source config still matches the canonical "openai" generated provider. Without this, the trim-only source lookup misses, the source SecretRef marker is never reapplied, and resolved runtime secret values leak into generated models.json. Adds plan-level regressions in models-config.runtime-source-snapshot.test.ts covering mixed-case apiKey and header source configs. * fix: use Array#toSorted in mixed-case provider regression tests oxlint(no-array-sort) flagged the new test assertions for using .sort() on Object.keys(...). Switch to .toSorted() to keep the check-lint shard green. * style(agents): oxfmt models-config provider merge files * fix(agents): define provider key collision precedence --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
* fix: normalize provider keys during model config merge * fix: normalize source-managed provider keys when reapplying secret markers Make enforceSourceManagedProviderSecrets canonicalize provider keys with normalizeProviderId so mixed-case (e.g. "OpenAI") source config still matches the canonical "openai" generated provider. Without this, the trim-only source lookup misses, the source SecretRef marker is never reapplied, and resolved runtime secret values leak into generated models.json. Adds plan-level regressions in models-config.runtime-source-snapshot.test.ts covering mixed-case apiKey and header source configs. * fix: use Array#toSorted in mixed-case provider regression tests oxlint(no-array-sort) flagged the new test assertions for using .sort() on Object.keys(...). Switch to .toSorted() to keep the check-lint shard green. * style(agents): oxfmt models-config provider merge files * fix(agents): define provider key collision precedence --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes a model config merge bug where provider map keys were only trimmed, not normalized as provider ids. If generated/catalog providers used
openaiand user config or existingmodels.jsonentries usedOpenAI, merge planning could produce duplicate provider entries or fail to preserve existing secrets onto the canonical provider.ClawSweeper review correctly flagged a paired issue at the secret-boundary: after canonicalizing keys in
mergeProviders, the source-managed marker enforcement (enforceSourceManagedProviderSecrets) was still doing a trim-only lookup against the original source provider key. That meant asourceConfigForSecretskeyed asOpenAIwould miss the now-canonicalopenaigenerated entry, the SecretRef marker would not be reapplied, and the resolved runtimeapiKeycould be written tomodels.jsonas plaintext. The follow-up closes that gap and moves every provider-map collision through one canonical helper.Why This Change Was Made
Provider ids are canonicalized by trimming and lowercasing. Generated, explicit, existing-secret, and source-managed provider maps now share one collision contract:
This keeps SecretRefs attached to the canonical provider while making mixed-case collision behavior deterministic.
User Impact
models.providersor existingmodels.jsonno longer get duplicate provider entries in generated model config. Explicit settings and preserved local secrets merge into the canonical provider id.models.providers.OpenAIwith{ source: "env", id: "OPENAI_API_KEY" }) now correctly project back to the canonicalopenaigenerated entry as the env marker"OPENAI_API_KEY"instead of the resolved runtime secret value.Evidence
Real plan-level proof (
planOpenClawModelsJsonWithDeps) for a mixed-casesourceConfigForSecrets(models.providers.OpenAI = { apiKey: { source: "env", id: "OPENAI_API_KEY" } }) against a runtime config whose apiKey has already been resolved tosk-runtime-resolved.Before this PR (trim-only lookup) — runtime secret leaks into generated
models.json:{ "providers": { "openai": { "baseUrl": "https://api.openai.com/v1", "apiKey": "sk-runtime-resolved", "api": "openai-completions", "models": [] } } }After this PR — source SecretRef env marker is reapplied:
{ "providers": { "openai": { "baseUrl": "https://api.openai.com/v1", "apiKey": "OPENAI_API_KEY", "api": "openai-completions", "models": [] } } }Both snapshots use synthetic non-secret values.
Regression proof on Linux Node 24, AWS Crabbox run
run_cd25bdec60f7:src/agents/models-config.merge.test.ts: 21/21 passed, including canonical-before-alias, alias-before-canonical, alias-only, and existing SecretRef collisions.src/agents/models-config.runtime-source-snapshot.test.ts: 11/11 passed, including both key orders and malformed canonical source data with a valid alias.git diff --checkclean.