fix(chutes): add graceful fallback for model parsing #10279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where the Chutes API returns an empty object
{}at the end of their models array, which caused the entire Zod parse to fail and prevented all dynamic models from loading.This change aligns the Chutes provider with the OpenRouter fallback pattern for more robust API response handling.
Changes
response.data.data(mirrors OpenRouter pattern)id, missingcontext_length)maxTokensfallback calculation (contextWindow * 0.2) whenmax_model_lenis missingTesting
MiniMaxAI/MiniMax-M2) now appear in the UIImportant
Fixes Chutes API model parsing by making schema fields optional and adding fallbacks for invalid data, with new test cases for edge cases.
ChutesModelSchemaoptional inchutes.tsfor robust parsing of incomplete API responses.response.data.dataif schema validation fails, mirroring OpenRouter pattern.id, missingcontext_length) ingetChutesModels().maxTokensascontextWindow * 0.2ifmax_model_lenis missing.chutes.spec.tsfor edge cases: empty objects, missingid, missingcontext_length, and mixed valid/invalid items.This description was created by
for 3daea7f. You can customize this summary. It will automatically update as commits are pushed.