← Back to PRs

#21638: fix(models): surface models.json validation errors instead of failing silently

by aldoeliacim open 2026-02-20 06:03 View on GitHub →
agents size: XS trusted-contributor
## 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