Bug fix in modified action delete API#5351
Merged
m4dcoder merged 4 commits intoStackStorm:masterfrom Sep 14, 2021
Merged
Conversation
m4dcoder
requested changes
Sep 2, 2021
| ) | ||
| action = ActionAPI.from_model(action_db) | ||
| action_db = ActionAPI.to_model(action) | ||
| Action.add_or_update(action_db) |
Contributor
There was a problem hiding this comment.
Can you modify the unit tests to cover this change?
| e, | ||
| ) | ||
| action = ActionAPI.from_model(action_db) | ||
| action_db = ActionAPI.to_model(action) |
Contributor
There was a problem hiding this comment.
Why do we need to covert the models to ActionAPI and back to ActionDB here?
Contributor
Author
|
@m4dcoder I have polished code and added new unit test to cover the made changes. Please review. |
m4dcoder
requested changes
Sep 3, 2021
| self.__get_action_id(post_resp), expect_errors=True | ||
| ) | ||
| self.assertEqual(del_resp.status_int, 500) | ||
| self.assertEqual(del_resp.json["faultstring"], msg) |
Contributor
There was a problem hiding this comment.
Can you add a check to make sure that ACTION_1 is added back to the database?
m4dcoder
requested changes
Sep 3, 2021
| ) | ||
| action_db.id = None | ||
| Action.add_or_update(action_db) | ||
| abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(e)) |
Contributor
There was a problem hiding this comment.
Also, if the deletion is related to permission error, can you change the error code to 403 Forbidden here? Otherwise for any other error, return 500 is fine.
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently if PermissionError (or any other exception) occurs during removing files from disk, action delete operation deregisters the action from database but action files remains in filesystem i.e. this operation leaving st2 in an inconsistent state. So, it is required to rollback the operation and register action to database again if such case occurs.