refactor(openrouter): remove unused properties from cron job Zod schemas#2575
refactor(openrouter): remove unused properties from cron job Zod schemas#2575kilo-code-bot[bot] wants to merge 6 commits intomainfrom
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Reviewed by gpt-5.4-20260305 · 920,797 tokens |
| input_modalities: z.array(z.string()), | ||
| output_modalities: z.array(z.string()), | ||
| has_text_output: z.boolean(), | ||
| group: z.string(), |
There was a problem hiding this comment.
WARNING: This makes existing models_by_provider.data rows unreadable until the cron job rewrites them
The previous commit intentionally stripped group out of the normalized snapshot, so the latest persisted rows in models_by_provider do not have this property. useOpenRouterModelsAndProviders() reparses that stored JSON with NormalizedOpenRouterResponse, so making group required here will reject the current DB payload and break the models-by-provider page until sync-providers runs again.
There was a problem hiding this comment.
The concern isn't valid here: this PR has not been deployed to production, so all existing models_by_provider rows were written by the pre-PR cron job which did include group in the stored JSON (it was part of the original OpenRouterBaseModel schema). There is no window where rows without group could have been persisted in production. Zod will find the field present in every real DB row and parse it correctly.
74d050e to
e00512c
Compare
| return { | ||
| slug: base?.slug ?? `${randomChoice(rng, PROVIDERS)}/${modelName}`, | ||
| hf_slug: base?.hf_slug ?? null, | ||
| updated_at: base?.updated_at ?? new Date().toISOString(), |
There was a problem hiding this comment.
Dont we want this for debugging?
Summary
The `/api/cron/sync-providers` job fetches data from two OpenRouter API endpoints and stores a normalized subset in the DB. Large portions of the parsed response data were never read — either in the sync logic itself or downstream in the UI.
This PR removes all those unused fields, reducing the schemas to only what is actually consumed:
~300 lines deleted, no functional behaviour changed.
Verification
Visual Changes
N/A
Reviewer Notes
Zod's default strip mode means existing DB rows with the old (wider) JSON shapes will still parse fine — the extra fields are silently ignored on read. Both `group` and `updated_at` have always been present in stored rows (they were in the original schema before this PR), so making them required does not risk breaking any existing data.