Fix aliased Zammad model field parsing#2
Merged
Conversation
There was a problem hiding this comment.
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=Trueacross multiple models to allow population by Python field names even when aliases exist. - Updated
Article.ticket_idparsing to accept bothticket_idandticketId. - Added model tests to confirm
Articleaccepts both snake_case and camelCaseticket_idformats.
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ticketId,stateType, anduserIdsworking.ticket_id.Verification
uv run python -m pytest tests/test_models.py -q