Fix custom model objects with multiple keys being silently skipped#54
Merged
Conversation
resolveModelCollections checked for a single-key provider object before
the custom-model (`id`) branch, so a custom model like
`{ id, url, modelName }` failed the single-key check and was skipped with
a confusing "Must have exactly one key" warning — the `.id` branch was
unreachable dead code.
Restructure to a single object branch that checks `id` first (custom
model definition, passed through) and falls back to provider shorthand.
Also clarify the skip warning to mention the `id` option so the failure
is diagnosable.
Fixes #22
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUWffHt992rYTqivjW2V8e
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #22. Custom model definitions using object syntax with multiple fields (e.g.
{ id, url, modelName }) were silently skipped byresolveModelCollectionsand logged a confusing warning.Root cause
In
src/cli/commands/run-config.ts, the object branch checked for a single-key provider object ({ "provider": "modelName" }) before the custom-model branch. Since a custom model has multiple keys, it failed the single-key check and was skipped with anInvalid object entry... Must have exactly one keywarning. Theelse if (... && modelEntry.id)branch that was meant to handle custom models was unreachable — the precedingelse ifalready matched every non-array object.Changes
modelEntry.idfirst (custom model definition → passed through directly), falling back to the provider-shorthand path. This eliminates the ordering dependency rather than just reordering two sibling branches, so the skip can't silently reappear.idoption, so the failure is diagnosable instead of cryptic.{ id, url, modelName }case from the issue, and a mixed case (custom model + string literal + collection placeholder).Test plan
pnpm exec vitest run src/cli/commands/run-config.test.ts— 22 passed (including the 2 new tests, which return[]/ drop the model under the old code).tsc --noEmitclean for the touched files.Related issues
Fixes #22
🤖 Generated with Claude Code
Generated by Claude Code