Skip to content

fix(types): make ShowResponse.model_info optional so cloud models without model_info parse (#607)#684

Open
Missing-Identity wants to merge 1 commit into
ollama:mainfrom
Missing-Identity:fix/607-showresponse-missing-model-info
Open

fix(types): make ShowResponse.model_info optional so cloud models without model_info parse (#607)#684
Missing-Identity wants to merge 1 commit into
ollama:mainfrom
Missing-Identity:fix/607-showresponse-missing-model-info

Conversation

@Missing-Identity

Copy link
Copy Markdown

Summary

Fixes #607.

ShowResponse.modelinfo is annotated Optional[Mapping[str, Any]] but declared with Field(alias='model_info') and no default. In pydantic, a field with an alias and no default is still required at validation time, so any /api/show response that omits model_info raises:

pydantic_core._pydantic_core.ValidationError: 1 validation error for ShowResponse
model_info
  Field required [type=missing, ...]

This is observed with several cloud models whose /api/show payload does not include model_info (e.g. glm-4.7:cloud, qwen3-next:80b-cloud, deepseek-v3.2:cloud), and it breaks ollama.show() as well as downstream tools such as llm-ollama.

Every other field on ShowResponse (modified_at, template, modelfile, license, details, parameters, capabilities) already has a default and is therefore optional. modelinfo is the only field that is accidentally required.

Change

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

Giving the Field a default of None makes the field truly optional, matching its Optional[...] annotation and the rest of the model. The wire alias model_info is unchanged, so responses that include model_info continue to populate .modelinfo exactly as before.

Tests

Added two focused regression tests to tests/test_type_serialization.py:

  • test_show_response_missing_model_info — a payload without model_info now validates and .modelinfo is None (other fields like capabilities/template still parse).
  • test_show_response_with_model_info — a payload with model_info still populates .modelinfo correctly.

Full suite for the touched file:

12 passed in 0.15s

ruff reports All checks passed!.

Notes

This is a minimal, backwards-compatible change. No public API or wire format changes.

…hout model_info parse (ollama#607)

Co-authored-by: Unmilan Mukherjee <Missing-Identity@users.noreply.github.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.

ShowResponse ValidationError when /api/show omits model_info (cloud models)

2 participants