Skip to content

fix(tickets): handle bare object response and enable pagination#2

Merged
asachs01 merged 1 commit intomainfrom
fix/ticket-get-and-pagination
May 6, 2026
Merged

fix(tickets): handle bare object response and enable pagination#2
asachs01 merged 1 commit intomainfrom
fix/ticket-get-and-pagination

Conversation

@asachs01
Copy link
Copy Markdown
Member

@asachs01 asachs01 commented May 6, 2026

Summary

  • tickets.get() and actions.get() no longer crash with Cannot read properties of undefined (reading '0'). HaloPSA's GET /Tickets/{id} returns a bare Ticket object, not { tickets: [...] }. We now accept either shape.
  • tickets.list() and actions.list() now honor caller-supplied pageSize / pageNo. HaloPSA silently ignores those params unless pageinate=true (their typo) is also sent — buildListParams and the paginated iterator now set it automatically.

Why

Reported by an external user: halopsa_tickets_list always returned 50 results regardless of limit, and halopsa_tickets_get failed on every call.

Test plan

  • npm test (68 tests pass)
  • New test: tickets.get handles bare-object response shape

GET /Tickets/{id} and GET /Actions/{id} return the entity directly,
not wrapped in {tickets:[]}/{actions:[]} as the list endpoints do.
The SDK was unwrapping unconditionally, causing
"Cannot read properties of undefined (reading '0')" on every get call.

Also: HaloPSA silently ignores page_size/page_no unless `pageinate=true`
(their typo) is also sent. The SDK's list and pagination helpers now
include `pageinate=true` automatically when paging params are set,
so caller-supplied `pageSize` is honored instead of capping at 50.
@asachs01 asachs01 merged commit c822233 into main May 6, 2026
3 checks passed
@asachs01 asachs01 deleted the fix/ticket-get-and-pagination branch May 6, 2026 17:43
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
## [1.0.2](v1.0.1...v1.0.2) (2026-05-06)

### Bug Fixes

* **tickets:** handle bare object response and enable pagination ([#2](#2)) ([c822233](c822233))
asachs01 added a commit to wyre-technology/halopsa-mcp that referenced this pull request May 6, 2026
Picks up the SDK fixes for halopsa_tickets_get (bare-object response)
and halopsa_tickets_list pagination (`pageinate=true` requirement).

Companion to wyre-technology/node-halopsa#2 — do not merge until that
SDK release publishes to GHCR/npm.
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.

1 participant