Community Version 25.04.2 USB snapshot replication error - TypeError between instances of 'datetime.datetime' and 'NoneType'

I have been using replication to back up a dataset RaidZFS2 to an external USB drive. All has been fine with the periodic snapshots running each week but also including a regular expression .* for “also include snapshots with the name” set. The USB drive and raid have matching snapshots listed when checked (in the Datasets → Data Protection → Manage Snapshots web GUI).
I updated from 25.04.1 to 25.04.2 and received a strange error on the replication to the USB drive. The error given is:

Blockquote
TypeError: ‘<’ not supported between instances of ‘datetime.datetime’ and ‘NoneType’

The debug log shows some data.

Blockquote
[2025/08/08 08:09:53] ERROR [replication_task__task_3] [zettarepl.replication.run] For task ‘task_3’ unhandled replication error TypeError(“‘<’ not supported between instances of ‘datetime.datetime’ and ‘NoneType’”)
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/zettarepl/replication/run.py”, line 181, in run_replication_tasks
retry_contains_partially_complete_state(
File “/usr/lib/python3/dist-packages/zettarepl/replication/partially_complete_state.py”, line 16, in retry_contains_partially_complete_state
return func()
^^^^^^
File “/usr/lib/python3/dist-packages/zettarepl/replication/run.py”, line 182, in
lambda: run_replication_task_part(replication_task, source_dataset, src_context, dst_context,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
… 1 more lines …
pre_retention(src_context.context.now.replace(tzinfo=None), replication_task, src_context.datasets,
File “/usr/lib/python3/dist-packages/zettarepl/replication/pre_retention.py”, line 47, in pre_retention
RetentionBeforePushReplicationSnapshotOwner(target_dataset, now, replication_task, source_snapshots,
File “/usr/lib/python3/dist-packages/zettarepl/replication/pre_retention.py”, line 26, in init
incremental_base = get_parsed_incremental_base(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/zettarepl/replication/snapshots_to_send.py”, line 62, in get_parsed_incremental_base
return sorted(
^^^^^^^
TypeError: ‘<’ not supported between instances of ‘datetime.datetime’ and ‘NoneType’

Updating to the latest 25.04.2.1 didn’t fix it - same errors.
I saw some information on Reddit about changing to “Also Include Naming Schema” and added the 3 periodic snapshots as named schemas (with the relevant %Y-%m-%d_%H-%M time variables). The last line of the edit menu has the text “20 of 20 existing snapshots of dataset hdd_pool1 would be replicated with this task.” which is an excellen sign.
When I then run the replication manually, this completes successfully (without the above error) but the USB drive is missing the last 7 days snapshots. It has 12 snapshots present and these are dated to when the replication was last run (last Friday).

Is there anything I should do or should I hope that the replication works correctly next week (and hope that the automatic replication task works where a manual run one didn’t)?

Many thanks for your help/opinions.

Ta,
Cornishman.

This week, the replication task completed successfully and pushed the newly created snapshots to the USB drive. I have 13/20 snapshots now on the USB drive - missing a complete weeks worth. It looks like the system has decided that the snapshots have copied across even though they didn’t. My guess is that there is a database that stores what snapshots have copied across that has been marked as completed before the type error occured.
Since I have one set of backup snapshots stored I should be able to recover should the worst happen. All I have to do is wait for the snapshots to expire.

The fix is therefore to use the naming schema for backup snapshots included in the replication task and don’t sweat about missing snapshots during the change over.

Ta,
Cornishman