#21638: fix(models): surface models.json validation errors instead of failing silently
agents
size: XS
trusted-contributor
Cluster:
Wizard Enhancements and Config Fixes
## Problem
When `models.json` contains a validation error in **any single provider**, `ModelRegistry.validateConfig()` throws on the first error and `loadCustomModels()` returns an empty result via `emptyCustomModelsResult()`. This silently drops **ALL** custom models and provider-level `baseUrl` overrides — not just the broken provider.
The error is stored in `ModelRegistry.loadError` but never surfaced to the user. The gateway continues with built-in models only, causing hard-to-diagnose failures:
- Wrong `baseUrl` (e.g., proxy key sent to the real API → 401)
- Unexpected model fallbacks
- Auth cooldown accumulation
## Fix
After constructing `ModelRegistry`, check `getError()` and log a prominent `console.warn` so users can quickly identify the misconfigured provider.
This is the minimum viable fix ("Option B" from the issue). The ideal fix (per-provider validation with graceful skip) requires changes to the upstream `@mariozechner/pi-coding-agent` dependency.
## Testing
- `pnpm build` ✅
- `vitest run src/agents/model-catalog.test.ts` ✅ (3/3 pass)
Closes #21584
🤖 AI-assisted (Claude), lightly tested against existing test suite.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added validation error surfacing for `models.json` configuration errors via `console.warn`. Previously, validation failures silently dropped all custom models and provider overrides, causing hard-to-diagnose authentication and model fallback issues.
- Surfaces `ModelRegistry.getError()` output when validation fails
- Preserves existing behavior (continues with built-in models)
- Helps users quickly identify misconfigured providers
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a minimal, focused improvement that only adds diagnostic logging. It adds a type-safe check for `getError()`, logs the error via `console.warn`, and doesn't modify any control flow or data processing. The existing test suite passes, and the change addresses a real UX problem where configuration errors were silently dropped.
- No files require special attention
<sub>Last reviewed commit: 309999f</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19020: bugfix(gateway): Handle invalid model provider API config gracefully\…
by funkyjonx · 2026-02-17
79.5%
#9064: fix: validate model references against catalog in config.set/patch/...
by joetomasone · 2026-02-04
79.5%
#3322: fix: merge provider config api into registry model
by nulone · 2026-01-28
79.4%
#17469: Improve unknown-model errors for provider/model misconfiguration
by megahappyclaw · 2026-02-15
79.3%
#13626: fix(model): propagate provider model properties in fallback resolution
by mcaxtr · 2026-02-10
78.6%
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
78.6%
#9212: fix: ensure model.input is always an array for custom providers
by sparck75 · 2026-02-05
78.4%
#16766: fix(model): apply provider baseUrl/headers override to registry-fou...
by dzianisv · 2026-02-15
78.2%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
77.2%
#17021: fix(agents): read models from gateway config first
by Limitless2023 · 2026-02-15
76.9%