From 2ba285f414087d07e20a7665c672636da40b2c9e Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 18 Jul 2024 02:56:18 +0200 Subject: [PATCH] Fix POST /todo crashing on non-intable 'fill_for_' adoption values. --- plomtask/http.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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) -- 2.30.2