Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Doubt about the error message "An unexpected error occurred #13082

Closed
aerdnach opened this issue May 2, 2022 · 0 comments
Closed

Doubt about the error message "An unexpected error occurred #13082

aerdnach opened this issue May 2, 2022 · 0 comments

Comments

@aerdnach
Copy link

aerdnach commented May 2, 2022

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

@directus directus locked and limited conversation to collaborators May 2, 2022
@azrikahar azrikahar converted this issue into discussion #13083 May 2, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant