Skip to content

zammad_get_ticket returns "Unknown" for State, Priority, Group, Owner and Customer #319

Description

@jovamateus26

Describe the bug

zammad_get_ticket renders every human-readable field as Unknown, even though the ticket has them set. The zammad://ticket/{id} resource is affected too, since both go through ZammadClient.get_ticket.

Root cause

get_ticket fetches the ticket with self.api.ticket.find(ticket_id) (client.py#L196). zammad_py's Resource.find() takes only an id and accepts no filters, so expand=true is never sent. Zammad then returns just the *_id fields, Ticket.state / .priority / .group / .owner / .customer stay None, and _brief_field falls through to its "Unknown" default.

search_tickets does not have the problem because it passes filters={..., "expand": "true"}. This looks like a spot that was missed when the expand handling was fixed — tests/test_expand_param_fix.py covers ticket.search, ticket.all, user.search and organization.search, but not the single-ticket find.

The models were already written for the expanded form (group: GroupBrief | str | None, with the comment "can be either objects or strings when expand=true"), so only the request side is missing.

To Reproduce

Against a Zammad 6.5 instance with a ticket that has a group, state, priority and customer:

zammad_get_ticket { "ticket_id": 3 }

Expected behavior

**State**: open
**Priority**: 2 normal
**Group**: CGT
**Customer**: jovanir

Actual behavior

**State**: Unknown
**Priority**: Unknown
**Group**: Unknown
**Owner**: Unknown
**Customer**: Unknown

zammad_search_tickets on the same ticket correctly reports State: open / Priority: 2 normal, which is a quick way to confirm the data is there.

Raw API for the same ticket:

GET /api/v1/tickets/3              -> "group_id":4, "state_id":2, "priority_id":2
GET /api/v1/tickets/3?expand=true  -> "group":"CGT", "state":"open", "priority":"2 normal"

Environment

  • mcp-zammad at 8873b2e (main), run via uvx --from git+https://github.com/basher83/zammad-mcp.git mcp-zammad
  • Zammad 6.5 (docker-compose), API token auth with ticket.agent
  • Python 3.12, Windows 11

Additional context

Possibly related, and not covered by this report: _brief_field only checks isinstance(value, StateBrief | PriorityBrief | UserBrief), so GroupBrief and OrganizationBrief objects would also fall through to "Unknown". It does not bite here because with expand=true Zammad sends plain strings, but it looks unintended.

PR incoming.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:infraInfrastructure, networking, and automationarea:pythonPython development and toolingarea:securitySecurity and policy workeffort:lowimpact:mediumstatus: pending-closeWork completed by Factory; awaiting maintainer closetype:bugSomething is not working correctlytype:securitySecurity-related work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions