fix(server): trim OpenCode provider model names#2252
fix(server): trim OpenCode provider model names#2252juliusmarminge merged 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Simple defensive fix that trims whitespace from model names and skips models with empty names. Uses an existing utility function already in the codebase, with minimal and predictable runtime impact. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Trim OpenCode-derived display strings before constructing
ServerProviderModelentries.Specifically:
model.nameprovider.namebefore using it assubProviderWhy
This fixes the nightly bug reported in #2251 where the app gets stuck on
waiting for provider status...if OpenCode returns model names with trailing whitespace.The shared contract requires trimmed non-empty strings for
ServerProviderModel.nameandsubProvider, butOpenCodeProviderwas forwarding upstream values verbatim. A single malformed model name causes the initial config snapshot to fail frontend decoding, which prevents provider state from initializing.Trimming at the OpenCode boundary is the smallest fix and keeps the bad upstream data from poisoning the snapshot payload.
Checklist
Note
Trim and validate model names in
flattenOpenCodeModelsModels with empty or whitespace-only names are now skipped, and valid names are trimmed before use. The
subProviderfield is only included when the provider name is non-empty after trimming. Changes are in OpenCodeProvider.ts.Macroscope summarized bfbb323.
Note
Low Risk
Low risk: small validation/sanitization change limited to OpenCode model metadata; main behavior change is skipping models with empty/whitespace-only names, which could hide bad upstream entries.
Overview
Trims and validates OpenCode-derived display strings when building
ServerProviderModelentries.flattenOpenCodeModelsnow usesnonEmptyTrimmedformodel.nameandprovider.name, skips models whose trimmed name is empty, and only includessubProviderwhen the provider name is non-empty after trimming to prevent malformed upstream data from breaking snapshots.Reviewed by Cursor Bugbot for commit bfbb323. Bugbot is set up for automated code reviews on this repo. Configure here.