Skip to content

fix(kosong): tolerate undefined model name in Anthropic profile matching - #3003

Open
silentiris wants to merge 1 commit into
MoonshotAI:mainfrom
silentiris:fix/anthropic-profile-undefined-model
Open

fix(kosong): tolerate undefined model name in Anthropic profile matching#3003
silentiris wants to merge 1 commit into
MoonshotAI:mainfrom
silentiris:fix/anthropic-profile-undefined-model

Conversation

@silentiris

Copy link
Copy Markdown

Related Issue

Resolve #2981

Problem

A malformed config entry — e.g. an unquoted dotted TOML key like [models.kimi-k2.7-code] — parses into a nested object that lacks the top-level model field. The v2 config schema marks model optional, so the entry reaches profile matching with undefined, crashing the getModels bridge call with TypeError: Cannot read properties of undefined (reading 'toLowerCase').

What changed

matchKnownAnthropicModelProfile, matchUnknownClaudeProfile, and parseAnthropicModelVersion now return undefined/null for undefined input instead of throwing. This degrades to "no Anthropic profile" for the malformed entry, matching the behavior for unrecognized model names, and prevents the entire getModels call from failing.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.

A malformed config entry (e.g. an unquoted dotted TOML key like
[models.kimi-k2.7-code]) parses into a nested object that lacks the
top-level model field. The v2 config schema marks model optional, so the
entry reaches profile matching with undefined, crashing getModels with
TypeError: Cannot read properties of undefined (reading 'toLowerCase').

matchKnownAnthropicModelProfile, matchUnknownClaudeProfile, and
parseAnthropicModelVersion now return undefined/null for undefined input
instead of throwing.

Fixes MoonshotAI#2981
@changeset-bot

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 558b1a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kosong Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

"Regression in 0.7.0: getModels crashes with Cannot read properties of undefined (reading 'toLowerCase')"

1 participant