Skip to content

fix: ShowResponse raises ValidationError when model_info is omitted#644

Closed
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:fix/show-response-model-info-validation
Closed

fix: ShowResponse raises ValidationError when model_info is omitted#644
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:fix/show-response-model-info-validation

Conversation

@CyberRaccoonTeam
Copy link
Copy Markdown

Summary

Fixes #607

ShowResponse raises a Pydantic ValidationError when the /api/show endpoint omits model_info from its response. This happens with some cloud models and breaks downstream tools like llm-ollama.

Root Cause

modelinfo uses Field(alias='model_info') with Optional[Mapping] type, but Pydantic requires an explicit default=None for aliased Optional fields. Without it, the field is treated as required even though the type hint suggests otherwise.

Changes

  • ollama/_types.py: Added model_config = ConfigDict(populate_by_name=True) and default=None to the modelinfo field on ShowResponse
  • tests/test_type_serialization.py: Added 3 tests covering the fix:
    • test_show_response_without_model_info — verifies no error when model_info is absent
    • test_show_response_with_model_info_alias — verifies the alias still works
    • test_show_response_with_modelinfo_field_name — verifies the Python field name works

Testing

13 passed in 0.18s

All existing tests continue to pass.

…bility

Pydantic requires explicit default=None for Optional fields with aliases.
Without it, ShowResponse raises ValidationError when /api/show omits
model_info, which happens with some cloud models.

Fixes #607
@CyberRaccoonTeam CyberRaccoonTeam closed this by deleting the head repository Apr 13, 2026
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)

1 participant