Remove triggers that have a malformed path #3121
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original Issue
A malformed path would crash the program on startup because the
Directory.CreateDirectory
method would throw an unhandled exception. This is a bigger issue if the workflow is persistent since the trigger will get created but there isn't a way to remove it if something goes wrong. Meaning that if you use aWatchDirectory
activity with an invalid path the project will fail to start until you change or remove the trigger in your database.How to create the original error
I used the project
ElsaDashboard.Samples.AspNetCore.Monolith
in the samples directory for testing since it already has Elsa server setup with SQLite as the persistence provider.I added file activities using
AddFileActivities()
in the Startup file and I started up the project. I created a new workflow that only has one activity: aWatchDirectory
activity and made the pathC:\Te|st
.I am using Windows and this is an invalid path due to the
|
. If you are running something Unix based try/test///directory
. The triple slashes should throw the same exception.Publish this workflow and you will see a wave of exceptions fill the console. Now, shutdown the project and restart it. It will fail to start and cannot be restarted until you remove or change the trigger and the workflow definition in the SQLite database.
This PR is for two things:
Directory.CreateDirectory
method and removes the trigger that caused the exception.To Test
Recreate the situation I described above using the
ElsaDashboard.Samples.AspNetCore.Monolith
project. This time though the exception will be logged to the console and the project can still be started. Meaning the user can edit the offending workflow from the UI.I also tested this with the Builder API. This is the workflow I made:
It will achieve the same result as when the designer is used. Even if you change the value of
WithPath
to something valid the trigger with the offending path is still there and the project will fail to start.