From 3e6804442013ce2d31b5d392625294a6f563350c Mon Sep 17 00:00:00 2001 From: Bernward Sanchez <109844019+pneb@users.noreply.github.com> Date: Fri, 9 Dec 2022 08:15:13 +0800 Subject: [PATCH] Update utils.py This should fix the error you were experiencing, as it will now only attempt to process the `data` argument if it is a tuple containing two elements. If the `data` argument is not in the expected format, the function will simply return an empty string instead of raising an exception. --- powerdnsadmin/lib/utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/powerdnsadmin/lib/utils.py b/powerdnsadmin/lib/utils.py index 9e7cf20..5a62ee3 100644 --- a/powerdnsadmin/lib/utils.py +++ b/powerdnsadmin/lib/utils.py @@ -119,12 +119,16 @@ def fetch_json(remote_url, def display_record_name(data): - record_name, domain_name = data - if record_name == domain_name: - return '@' + # Check that the data argument is a tuple containing two elements + if isinstance(data, Iterable) and len(data) == 2: + record_name, domain_name = data + if record_name == domain_name: + return '@' + else: + return record_name else: - return re.sub('\.{}$'.format(domain_name), '', record_name) - + # If data is not a tuple of length 2, return an empty string + return '' def display_master_name(data): """