From 17b64d1f665a163d174fea53d331e7c23320296e Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Fri, 6 Feb 2026 16:52:09 +0100 Subject: [PATCH] Prevent accidental clearing of default ticket status Enhanced save logic to protect against losing the default ticket status value when saving settings with an empty dropdown: - Only update to new value if a status is actually selected - Only allow clearing if reference data is loaded (dropdown has options) - Preserve existing value if dropdown is empty (no reference data) This fixes the issue where saving settings before reference data loaded would overwrite the previously configured default status with NULL, causing "Create Autotask ticket" to fail with error about missing default status. Co-Authored-By: Claude Sonnet 4.5 --- .../src/backend/app/main/routes_settings.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/containers/backupchecks/src/backend/app/main/routes_settings.py b/containers/backupchecks/src/backend/app/main/routes_settings.py index 65aaeb6..f7e772c 100644 --- a/containers/backupchecks/src/backend/app/main/routes_settings.py +++ b/containers/backupchecks/src/backend/app/main/routes_settings.py @@ -482,7 +482,15 @@ def settings(): if "autotask_default_ticket_status" in request.form: try: - settings.autotask_default_ticket_status = int(request.form.get("autotask_default_ticket_status") or 0) or None + form_value = request.form.get("autotask_default_ticket_status", "").strip() + if form_value: # Only update if a value was actually selected + settings.autotask_default_ticket_status = int(form_value) + elif form_value == "" and settings.autotask_default_ticket_status is not None: + # If explicitly cleared (empty string submitted) and was previously set, + # allow clearing only if reference data is loaded (dropdown has options) + if getattr(settings, "autotask_cached_ticket_statuses_json", None): + settings.autotask_default_ticket_status = None + # Otherwise: keep existing value (prevents accidental clearing when dropdown is empty) except (ValueError, TypeError): pass