-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error out when trying to delete a location that has children #437
Conversation
Can we solve this by propagating error messages returned from the server instead? |
Yes and no. In this particular case the http code is 200 :( |
Can we do a scoped search to find children? Also do we want to give an option to delete the children, too? |
You can't search for parent id, no :( What we could do instead of the search is to issue the delete and inspect the API answer, as it does contain the error, just not with the right http code. |
844a6c5
to
8c200ef
Compare
I've pushed two iterations moving the error detection to parsing the result instead of predicting the problem and surfacing the error message received from the API. Still a workaround, but feels nicer? |
8c200ef
to
52af0dd
Compare
changed, entity = self.resource_action(resource, 'destroy', payload) | ||
|
||
# this is a workaround for https://projects.theforeman.org/issues/26937 | ||
if entity and 'error' in entity and 'message' in entity['error']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this generic enough to have it in resource_action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is at least true for location and organization, as both are a taxonomy, and the bug linked is affecting all taxonomies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, i meant whether it can happen on other actions than delete, and whether we should employ it for create, update, you name it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I wasn't sure about that. and the json this API endpoint returns on errors is slightly different then all the other endpoints, so let's keep it in delete for now.
52af0dd
to
004abdd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my view, this is good to merge 👍
No description provided.