From d5e3734b35fd63203c7954d48fc15547eb0d3442 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Mon, 19 Jan 2026 13:15:08 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-19 13:15:08) --- .last-branch | 2 +- .../backend/app/integrations/autotask/client.py | 16 +++++++++++++++- docs/changelog.md | 8 ++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.last-branch b/.last-branch index efacb08..50bcf1d 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260119-04-autotask-ticket-registration +v20260119-05-autotask-create-itemid diff --git a/containers/backupchecks/src/backend/app/integrations/autotask/client.py b/containers/backupchecks/src/backend/app/integrations/autotask/client.py index 0382e41..61794db 100644 --- a/containers/backupchecks/src/backend/app/integrations/autotask/client.py +++ b/containers/backupchecks/src/backend/app/integrations/autotask/client.py @@ -414,7 +414,10 @@ class AutotaskClient: raise AutotaskError("Ticket payload is empty.") data = self._request("POST", "Tickets", json_body=payload) - # Autotask commonly returns the created object or an items list. + # Autotask commonly returns only an itemId on create. + # We normalize that into a dict with an "id" key so callers can + # perform a follow-up GET /Tickets/{id} to retrieve the full object + # and the human-facing ticketNumber. if isinstance(data, dict): if "item" in data and isinstance(data.get("item"), dict): return data["item"] @@ -422,6 +425,17 @@ class AutotaskClient: first = data.get("items")[0] if isinstance(first, dict): return first + # Autotask create responses often look like: {"itemId": 12345} + item_id = data.get("itemId") + if item_id is None: + item_id = data.get("itemID") + if item_id is not None: + try: + tid = int(item_id) + except Exception: + tid = 0 + if tid > 0: + return {"id": tid} if "id" in data: return data # Fallback: return normalized first item if possible diff --git a/docs/changelog.md b/docs/changelog.md index 08516c9..2a3e9da 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -233,6 +233,14 @@ Changes: - Added repair/propagation logic so runs that already have an Autotask ticket ID but lack internal linking are corrected automatically. - Guaranteed that future runs for the same job inherit the existing Autotask and internal ticket associations. +## v20260119-05-autotask-create-itemid + +### Changes: +- Updated Autotask ticket creation handling to treat a POST response containing only {"itemId": } as a successful ticket creation. +- Normalized the create response so the returned itemId is mapped internally to a ticket id, ensuring the existing follow-up GET /Tickets/{id} flow is always executed. +- Fixed erroneous failure condition where ticket creation was rejected because Autotask did not return a full ticket object. +- Restored compatibility with Autotask’s documented behavior for ticket creation responses. + *** ## v0.1.21