Skip to content

Fix aliased Zammad model field parsing#2

Merged
teodortalov merged 2 commits into
mainfrom
fix/article-ticket-id-alias
Jul 7, 2026
Merged

Fix aliased Zammad model field parsing#2
teodortalov merged 2 commits into
mainfrom
fix/article-ticket-id-alias

Conversation

@teodortalov

Copy link
Copy Markdown
Member

Summary

  • Allows Pydantic models to populate aliased fields by Python field name.
  • Keeps API aliases like ticketId, stateType, and userIds working.
  • Fixes article parsing for Zammad API responses that return ticket_id.

Verification

  • uv run python -m pytest tests/test_models.py -q

Copilot AI review requested due to automatic review settings July 7, 2026 19:18
@teodortalov teodortalov merged commit 84d8aca into main Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the Zammad Pydantic models to better handle aliased fields during parsing, specifically ensuring Article.ticket_id can be populated from both snake_case and camelCase Zammad API response keys.

Changes:

  • Enabled populate_by_name=True across multiple models to allow population by Python field names even when aliases exist.
  • Updated Article.ticket_id parsing to accept both ticket_id and ticketId.
  • Added model tests to confirm Article accepts both snake_case and camelCase ticket_id formats.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/zammad_mcp_server/models.py Adjusts model config to populate by field name and updates Article.ticket_id alias handling.
tests/test_models.py Adds regression tests for Article.ticket_id parsing from both ticket_id and ticketId.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


id: int
ticket_id: int = Field(alias="ticketId")
ticket_id: int = Field(validation_alias=AliasChoices("ticket_id", "ticketId"))
"""Brief state information."""

model_config = ConfigDict(extra="allow")
model_config = ConfigDict(extra="allow", populate_by_name=True)
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.

2 participants