Observe that the commandlet crashes. Each of these functions tries to interact with a slate window, regardless of setting the dialogue box boolean to false.
Thank you for providing the information and detailed reproduction steps.
I was unable to reproduce the issue using the provided steps in UE 5.6. In my testing, DeleteAssets worked as expected. This suggests the crash may be related to the specific project setup or particular assets involved.
In this case, the functions in ObjectTools or AssetTools operate at the UI layer. These utilities wrap lower-level systems and may attempt to display confirmation dialogs, which can lead to failures when running in a commandlet or unattended environment.
To help prevent unintended Slate modal interactions, you may consider explicitly setting:
GIsRunningUnattendedScript = true
Additionally, cleaning the Intermediate folder may help, especially if there are duplicated generated or renamed assets or stale redirectors.
If this case allows, reviewing UResavePackagesCommandlet may also be beneficial. It demonstrates how to operate at the package level in a commandlet-safe manner.
If you’re able to share additional context about this case, or a minimal repro project, it would greatly assist us in investigating the issue further.
DeleteAssets completes successfully, and CloseAllEditorsForAsset is also executed without any issues.
The crash appears to be related to an invalid or dirty memory access. This type of issue can be subtle and may be specific to your project’s implementation or to certain assets within it.
Since there is limited context of the implementation, it’s difficult to determine the exact cause on your end. If you could provide additional details about this case or share a minimal reproducible project, that would greatly help us investigate the issue further.
If I call the Cleanup function directly from the commandlet, the DeleteObject() call does not fail. It only fails when executed from the network callback.
[mention removed] - I can confirm that ObjectTools still fails when forced to run from the GameThread. In my example, Cleanup() is running on the main thread - whether I execute the network call or not. It seems like the network call just puts the commandlet in an undefined state.
Unfortunately, my Cleanup operation must run after the network call, since the data we are using the determine deletion relies on an external web-hosted database.
It looks like my only option here would be to split this into two commandlets, then - one to make the network calls and one to run cleanup?
I’m wondering whether the cleanup runs only after the HTTP request has fully completed, or if there might be an issue in the HTTP request implementation itself.
That said, since the deletion criteria depends on data, caching the data and splitting it into two separate commandlets is actually a very clean and robust approach.