Skip to content

fix(server): trim OpenCode provider model names#2252

Merged
juliusmarminge merged 1 commit intopingdotgg:mainfrom
adinschmidt:fix/opencode-trim-model-names
Apr 21, 2026
Merged

fix(server): trim OpenCode provider model names#2252
juliusmarminge merged 1 commit intopingdotgg:mainfrom
adinschmidt:fix/opencode-trim-model-names

Conversation

@adinschmidt
Copy link
Copy Markdown
Contributor

@adinschmidt adinschmidt commented Apr 21, 2026

What Changed

Trim OpenCode-derived display strings before constructing ServerProviderModel entries.

Specifically:

  • trim model.name
  • trim provider.name before using it as subProvider
  • skip models whose trimmed display name is empty

Why

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.name and subProvider, but OpenCodeProvider was 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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Trim and validate model names in flattenOpenCodeModels

Models with empty or whitespace-only names are now skipped, and valid names are trimmed before use. The subProvider field 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 ServerProviderModel entries.

flattenOpenCodeModels now uses nonEmptyTrimmed for model.name and provider.name, skips models whose trimmed name is empty, and only includes subProvider when 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1793fb72-0cdc-456b-b9b5-e99d9dfabcfa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 21, 2026
@adinschmidt adinschmidt marked this pull request as ready for review April 21, 2026 00:40
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 21, 2026

Approvability

Verdict: 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.

@juliusmarminge juliusmarminge enabled auto-merge (squash) April 21, 2026 02:42
@juliusmarminge juliusmarminge merged commit 40b3a80 into pingdotgg:main Apr 21, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants