I can't reproduce the error from #26630 locally, but from analying the logs I think the problem is the following:
After calling sync_blocks, we didn't check that the indexes have caught up to the tip before performing the manual pruning. This could possibly lead to prune blockers with a lower height than the expected 2489, which do appear in the logs of the failed CI runs, e.g.
2022-10-27T21:14:17.703920Z [C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\src\validation.cpp:2395] [FlushStateToDisk] [prune] coinstatsindex limited pruning to height 2488(Cirrus)
So, this should be fixed by a call to sync_index.
Fixes #26330