From: Christian Heller Date: Thu, 18 Jul 2024 00:56:18 +0000 (+0200) Subject: Fix POST /todo crashing on non-intable 'fill_for_' adoption values. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/edit?a=commitdiff_plain;h=2ba285f414087d07e20a7665c672636da40b2c9e;p=plomtask Fix POST /todo crashing on non-intable 'fill_for_' adoption values. --- diff --git a/plomtask/http.py b/plomtask/http.py index 2aa5215..c7678a7 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -646,20 +646,21 @@ class TaskHandler(BaseHTTPRequestHandler): comment = self._form_data.get_str('comment', ignore_strict=True) for v in fill_fors.values(): target_id: int - for prefix in ['make_empty_', 'make_full_']: - if v.startswith(prefix): - try: - target_id = int(v[len(prefix):]) - except ValueError as e: - msg = 'bad fill_for target: {v}' - raise BadFormatException(msg) from e - continue + to_int = v + for prefix in [p for p in ['make_empty_', 'make_full_'] + if v.startswith(p)]: + to_int = v[len(prefix):] + try: + target_id = int(to_int) + except ValueError as e: + msg = 'bad fill_for target: {v}' + raise BadFormatException(msg) from e if v.startswith('make_empty_'): processes_to_make_empty += [target_id] elif v.startswith('make_full_'): processes_to_make_full += [target_id] elif v != 'ignore': - adopted_child_ids += [int(v)] + adopted_child_ids += [target_id] to_remove = [] for child in todo.children: assert isinstance(child.id_, int)