Skip to content

Conversation

@yurekami
Copy link

Summary

Problem

The model_info field in ShowResponse was defined as:

modelinfo: Optional[Mapping[str, Any]] = Field(alias='model_info')

In Pydantic, Optional[...] means the value can be None, but Field() without a default still makes the field required (must be present in input). This caused a ValidationError when the server response doesn't include model_info.

Affected cloud models include:

  • glm-4.7:cloud
  • qwen3-next:80b-cloud
  • deepseek-v3.2:cloud

Solution

Changed to:

modelinfo: Optional[Mapping[str, Any]] = Field(default=None, alias='model_info')

This makes the field truly optional - it can be absent from the input data and will default to None.

Test plan

  • Added test_show_response_without_model_info - verifies ShowResponse can be created without model_info field
  • Added test_show_response_with_model_info - verifies ShowResponse still works when model_info is provided
  • All existing tests pass

🤖 Generated with Claude Code

The `model_info` field in ShowResponse was defined with `Field(alias='model_info')`
without a default value, making it required even though the type is `Optional`.

This caused a ValidationError when the `/api/show` endpoint omits the `model_info`
field, which happens with certain cloud models like:
- glm-4.7:cloud
- qwen3-next:80b-cloud
- deepseek-v3.2:cloud

The fix adds `default=None` to the Field definition, making the field truly optional
(can be absent from input data) and defaulting to `None`.

Fixes ollama#607

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant