You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Collection A with two fields: id and a text field named fieldA. Also I have another collection with three fields: an id, a text field named fieldB, and a relational field named retationWithA as a M2O relation with collection A; moreover on this field i set a PREVENT relational trigger, so that a deletion of an item in collection A is prevented if there is at least one item in collection B that references it.
With this in mind, I would like to explain my doubt. If I delete an item in Collection A, which is referenced by an item in Collection B, with a user with Administrator role I get an error 500 with the following message
"[INTERNAL_SERVER_ERROR] delete from "Collection_A" where "id" in ($1) - update or delete on table "Collection_A" violates foreign key constraint "collection_b_retationwitha_foreign" on table "Collection_B".
This way I know that if I want to delete the item in collection A I must first delete the items that reference it in collection B. On the other hand, if I make a deletion with a role that does not have administrator rights an error 500 with the message "[INTERNAL_SERVER_ERROR] An unexpected error occurred", without any details on what happened, and without being able to remedy what happened, considering also that it could be the non-administrator user who created the collections, and should know that he is violating a constraint that he has defined.
What I would expect is for the non-admin user to receive the same error as the admin user, so that he or she can perform the necessary actions to fix the problem. I also think that a 5xx error (server error) would not be appropriate in such a scenario, but that a 4xx error (client error) would be more appropriate (perhaps a 409 error), since the error is caused by a user operation that violates a constraint in the data model that the user has defined.
This was a long post. Thanks for your attention :)
To Reproduce
See in description.
Errors Shown
[INTERNAL_SERVER_ERROR] An unexpected error occurred
What version of Directus are you using?
9.9.1
What version of Node.js are you using?
16.15
What database are you using?
postgres
What browser are you using?
chrome
How are you deploying Directus?
locally
The text was updated successfully, but these errors were encountered:
Describe the Bug
I have a Collection A with two fields: id and a text field named fieldA. Also I have another collection with three fields: an id, a text field named fieldB, and a relational field named retationWithA as a M2O relation with collection A; moreover on this field i set a PREVENT relational trigger, so that a deletion of an item in collection A is prevented if there is at least one item in collection B that references it.
With this in mind, I would like to explain my doubt. If I delete an item in Collection A, which is referenced by an item in Collection B, with a user with Administrator role I get an error 500 with the following message
"[INTERNAL_SERVER_ERROR] delete from "Collection_A" where "id" in ($1) - update or delete on table "Collection_A" violates foreign key constraint "collection_b_retationwitha_foreign" on table "Collection_B".
This way I know that if I want to delete the item in collection A I must first delete the items that reference it in collection B. On the other hand, if I make a deletion with a role that does not have administrator rights an error 500 with the message "[INTERNAL_SERVER_ERROR] An unexpected error occurred", without any details on what happened, and without being able to remedy what happened, considering also that it could be the non-administrator user who created the collections, and should know that he is violating a constraint that he has defined.
What I would expect is for the non-admin user to receive the same error as the admin user, so that he or she can perform the necessary actions to fix the problem. I also think that a 5xx error (server error) would not be appropriate in such a scenario, but that a 4xx error (client error) would be more appropriate (perhaps a 409 error), since the error is caused by a user operation that violates a constraint in the data model that the user has defined.
This was a long post. Thanks for your attention :)
To Reproduce
See in description.
Errors Shown
[INTERNAL_SERVER_ERROR] An unexpected error occurred
What version of Directus are you using?
9.9.1
What version of Node.js are you using?
16.15
What database are you using?
postgres
What browser are you using?
chrome
How are you deploying Directus?
locally
The text was updated successfully, but these errors were encountered: