Fix purge requests without a creation start time - #616
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ed5b5ae5-2c5e-4422-9786-a23ad1618634
| The results of the request to purge history | ||
| """ | ||
| if created_time_from is None: | ||
| created_time_from = datetime.min |
There was a problem hiding this comment.
It's my understanding that datetime.min results in a date like 0001-01-01T00:00:00.000000Z. One concern I have is whether all the backends are able to correctly interpret such an early date. Some backends, like MSSQL, are sensitive about date ranges and might choke on this. Consider whether something like 2000-01-01T00:00:00.000000Z would be better.
| mock_request = MockRequest( | ||
| expected_url=f"{RPC_BASE_URL}instances/" | ||
| "?createdTimeFrom=0001-01-01T00:00:00.000000Z" | ||
| "&runtimeStatus=Running", |
There was a problem hiding this comment.
nit: I don't think purging "Running" instances is actually valid, so I suggest that these tests use a valid status filter to avoid confusing readers (or agents) about what a valid use case for purge is.
|
|
||
| ### Fixed | ||
|
|
||
| - `purge_instance_history_by` now supplies the earliest supported creation time when `created_time_from` is omitted, avoiding HTTP 400 responses from the Durable extension. |
There was a problem hiding this comment.
One risk from this change is that an API call that previously returned a 400 now attempts to delete everything, which can be quite destructive. I'm not as familiar with the original issue, but we should think carefully about whether this risk is worth the benefit.
Summary
purge_instance_history_bytodatetime.minwhencreated_time_fromis omittedThe Durable extension intentionally requires
createdTimeFromso a bare collectionDELETEcannot become an accidental unfiltered purge. The SDK method explicitly exposescreated_time_fromas optional, so it now translates that omission into an explicit lower bound instead.Fixes #560
Fixes #533
Fixes #470
Testing
python -m pytest -q tests\models\test_DurableOrchestrationClient.py tests\models\test_RpcManagementOptions.pypython -m flake8 azure\durable_functions\models\DurableOrchestrationClient.py azure\durable_functions\models\RpcManagementOptions.py