Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/omniroute-combos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function resolveUnderlyingModels(
const combo = combos.get(modelId);
if (combo) {
console.log(`[OmniRoute] Resolved combo "${modelId}" to ${combo.models.length} underlying models`);
return combo.models;
return combo.models.map((m: any) => typeof m === 'string' ? m : (m.model || m.id));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current implementation is vulnerable to runtime crashes if the models array contains null values or objects that lack both model and id properties. Specifically, (m.model || m.id) will throw if m is null, and if both properties are missing, the map will return undefined. This leads to a crash in splitModelId (called later in calculateModelCapabilities) when it attempts to call .trim() on a non-string value.

Additionally, the OmniRouteCombo interface (line 17) should be updated to reflect the new API response structure (e.g., models: (string | { model?: string; id?: string })[]), which would allow for proper type checking instead of relying on any.

Suggested change
return combo.models.map((m: any) => typeof m === 'string' ? m : (m.model || m.id));
return combo.models.map((m: any) => typeof m === 'string' ? m : (m?.model ?? m?.id)).filter((m): m is string => typeof m === 'string');

}

// Not a combo, return as-is
Expand Down