fix(client): request expand=true when fetching a single ticket - #321
fix(client): request expand=true when fetching a single ticket#321jovamateus26 wants to merge 1 commit into
Conversation
get_ticket called api.ticket.find(), and zammad_py's Resource.find()
accepts no filters, so expand=true was never sent. Zammad then returns
only the *_id fields, and _format_ticket_detail_markdown / the
zammad://ticket/{id} resource render State, Priority, Group, Owner and
Customer as "Unknown".
Fetch the ticket through zammad_py's session instead, following the same
pattern already used by list_tags, so the lowercase "true" expand flag
gets through. The Ticket model already accepts the expanded string form.
Verified against a live Zammad 6 instance: State/Priority/Group/Owner/
Customer now render real values instead of "Unknown".
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Walkthrough
ChangesExpanded ticket retrieval
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The ticket-fetching path now requests expanded fields so State, Priority, Group, Owner, and Customer render correctly. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 7 minor |
🟢 Metrics 0 complexity
Metric Results Complexity 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Heads-up on the two red/pending checks, neither of which I think is a defect in this patch — but both are your call. 1. The GitHub Actions workflows are waiting on you. 2. Codacy's 7 "new issues" are all Info-level pydocstyle findings that contradict this repo's own docstring convention. The full list:
D213 fires on every multi-line docstring whose summary sits on the first line — which is the entire codebase. D406/D407 ask for numpy-style section headers ( The clean proof is in the sibling PR #322, which mostly deletes code: Codacy reports 12 issues "Fixed", and they are the same D213/D406/D407/D413 patterns — in code that was already on I'd rather not adopt a foreign docstring style in one file just to clear the gate, but I'm not attached to that. Options, your pick:
|
Fixes #319
Problem
zammad_get_ticket— and thezammad://ticket/{id}resource, which shares the same client method — renders State, Priority, Group, Owner and Customer asUnknownfor every ticket.get_ticketfetched the ticket withapi.ticket.find(ticket_id), andzammad_py'sResource.find()accepts no filters, soexpand=truenever reached Zammad. Without it the API returns only*_idfields, the optionalTicketfields stayNone, and_brief_fieldfalls back to"Unknown".search_ticketswas unaffected because it passesfilters={..., "expand": "true"}— this is the one call site the earlier expand work (tests/test_expand_param_fix.py) could not cover, sincefind()has no filters parameter at all.Change
Fetch the ticket through
zammad_py's session withparams={"expand": "true"}, in a small_find_ticket_expandedhelper. This follows the patternlist_tagsalready uses for thetag_listendpoint, and keeps the lowercase"true"that the existing tests care about (Zammad is case-sensitive here andrequestsserializes boolTrueas"True").On failure it raises
requests.HTTPError(response.text)— same shapezammad_pyproduces — so the server'sTicketIdGuidanceErrormapping, which looks for"couldn't find"in the message, still fires for a bad ticket id.No model changes were needed:
Ticketalready declaresgroup: GroupBrief | str | Noneand friends, with a comment noting the string form arrives whenexpand=true.Tests
get_tickettests to mock the session response instead ofticket.find.test_get_ticket_requests_expanded_fields— asserts the exact URL and thatexpandis the literal"true", and that the expanded names survive.test_get_ticket_not_found_raises_with_zammad_message— asserts Zammad's error body survives, so the ticket-id guidance keeps working.224 passed, coverage 88.47% (gate 86%).
ruff check,ruff format --checkandmypy mcp_zammadall clean on the touched files.Verification against a real instance
Zammad 6.5, ticket #27003, before and after:
Note
Out of scope here, but flagged in the issue:
_brief_fieldonly checksisinstance(value, StateBrief | PriorityBrief | UserBrief), so aGroupBrieforOrganizationBriefobject would still yield"Unknown". It does not bite withexpand=true(Zammad sends plain strings), so I left it alone — happy to fold in a one-liner if you want it.Summary by CodeRabbit