From 6dfc44056ebea8c69a30c49f3e609e45a79e39f6 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 2 Apr 2026 19:14:20 +0200 Subject: [PATCH] Fix timestamp parsing in job import/export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use datetime.fromisoformat() instead of strptime with a rigid format that requires microseconds. When datetime.isoformat() produces timestamps without microseconds (e.g. "2026-04-02T14:28:40"), the strptime format "%Y-%m-%dT%H:%M:%S.%f" fails silently, leaving update_time/create_time as None on the restored model object. Also guard against None timestamps on the export side to prevent AttributeError when update_time or create_time is None. The try/except: pass was silently swallowing parse errors for 5 years, making it impossible to debug when timestamps failed to restore. Just check for key presence instead — if the value exists but is malformed, let it fail loudly. These fields are required by downstream code, so silently skipping them just delays the failure. Let KeyError or ValueError surface at the actual point of failure. Fixes https://github.com/galaxyproject/galaxy/issues/22371 --- lib/galaxy/model/store/__init__.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/model/store/__init__.py b/lib/galaxy/model/store/__init__.py index e7ce5548bb1..24917a2fbba 100644 --- a/lib/galaxy/model/store/__init__.py +++ b/lib/galaxy/model/store/__init__.py @@ -1691,14 +1691,8 @@ class BaseDirectoryImportModelStore(ModelImportStore): def restore_times( model_object: Union[model.Job, model.WorkflowInvocation, model.WorkflowInvocationStep], attrs: dict[str, Any] ) -> None: - try: - model_object.create_time = datetime.datetime.strptime(attrs["create_time"], "%Y-%m-%dT%H:%M:%S.%f") - except Exception: - pass - try: - model_object.update_time = datetime.datetime.strptime(attrs["update_time"], "%Y-%m-%dT%H:%M:%S.%f") - except Exception: - pass + model_object.create_time = datetime.datetime.fromisoformat(attrs["create_time"]) + model_object.update_time = datetime.datetime.fromisoformat(attrs["update_time"]) class DirectoryImportModelStore1901(BaseDirectoryImportModelStore):