Skip to content

fix: parse combo models correctly when returned as objects#11

Merged
Alph4d0g merged 4 commits into
Alph4d0g:mainfrom
herjarsa:fix/combo-models
May 12, 2026
Merged

fix: parse combo models correctly when returned as objects#11
Alph4d0g merged 4 commits into
Alph4d0g:mainfrom
herjarsa:fix/combo-models

Conversation

@herjarsa
Copy link
Copy Markdown
Contributor

The OmniRoute API /api/combos recent update returns an array of objects for underlying models instead of an array of strings. This caused opencode-omniroute-auth to crash when calling modelId.trim() in splitModelId. This PR adds a map to properly extract the model or id property if it is returned as an object. Confirmed to resolve the issue with standard combos like Combo-FIX recovering access to the full model index.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the resolveUnderlyingModels function to correctly extract model identifiers from the models array, which may now contain objects. Feedback was provided regarding potential runtime errors if the array contains null values or objects without the expected properties, recommending a safer mapping implementation and an update to the OmniRouteCombo interface for better type safety.

Comment thread src/omniroute-combos.ts Outdated
Alph4d0g added 2 commits May 11, 2026 12:57
- Replace unsafe 'any' with runtime type narrowing
- Handle null/undefined entries in the models array
- Filter out unresolvable entries instead of propagating undefined
- Keeps backward compatibility with string arrays
@Alph4d0g
Copy link
Copy Markdown
Owner

Thanks @herjarsa for opening this PR and catching the API change so quickly! The crash from .trim() on object-shaped model entries was a real issue, and your fix points exactly at the right spot.

I really appreciate you taking the time to debug this and confirm it resolves the problem with standard combos like Combo-FIX.

I've pushed two small atomic commits on top of your branch to harden the implementation before we merge:

  1. types: update OmniRouteCombo.models to accept objects from API — Updates the interface so models reflects the new API shape (Array<string | { model?: string; id?: string }>) instead of the old string[].

  2. fix: harden resolveUnderlyingModels against null and missing properties — Replaces the any assertion with runtime type narrowing, handles null/undefined entries safely, and filters out unresolvable items with a warning rather than letting undefined propagate downstream and crash later.

The logic is still fully backward-compatible with string arrays, and the build passes cleanly.

@Alph4d0g Alph4d0g marked this pull request as draft May 11, 2026 19:45
@Alph4d0g Alph4d0g marked this pull request as ready for review May 11, 2026 19:46
@Alph4d0g Alph4d0g merged commit c891ba9 into Alph4d0g:main May 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants