Skip to content
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

Bad Request Status 400 on Delete for Answer, Question, Questionnaire, Experiment when not empty #71

Open
Meefish opened this issue Dec 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Meefish
Copy link

Meefish commented Dec 13, 2024

Error Message:

answerService.ts:63 Error deleting answer: Error: Failed to delete answer: {"$schema":"https://wildlifenl-uu-michi011.apps.cl01.cp.its.uu.nl/schemas/ErrorModel.json","title":"Bad Request","status":400,"detail":"(ID)=(03785751-db5f-4242-a77f-490b70f59e35) is still used by 'message'."}

at deleteAnswer (answerService.ts:60:1)
at async saveQuestionsAndAnswers (QuestionEdit.tsx:210:1)
@BasMichielsen
Copy link
Member

Technically any 4xx error is a client mistake. You should delete the Message first and then this Answer. I realize this is "uncomfortable" but it is not a bug, and the correct working of the API back-end is still guaranteed. I do think it is worthwhile to investigate a possibility for making this less uncomfortable on the client side. So let's make this issue an enhancement.

@BasMichielsen BasMichielsen added the enhancement New feature or request label Dec 15, 2024
@BasMichielsen BasMichielsen changed the title Bad Request Status 400: When trying to Delete a Question which is connected to a Message Bad Request Status 400 on Delete Answer when connected to a Message Dec 15, 2024
@BasMichielsen BasMichielsen changed the title Bad Request Status 400 on Delete Answer when connected to a Message Bad Request Status 400 on Delete for Answer, Question, Questionnaire, Experiment when not empty Feb 11, 2025
@BasMichielsen
Copy link
Member

This issue arises in all DELETE calls for Answer, Question, Questionnaire and Experiment when attempting to delete them from the system and they are not "empty". Where empty means that there is still a child object connected to this object, in other words, the relational DB still has a record in another table having a foreign key that points to the primary key of this record.

It is possible to resolve the "uncomfortable" aspect of this issue by changing the ON DELETE part of the table to CASCADE instead of RESTRICT. However, for the sake of prudence we have decided to NOT do this yet but may do so in the future.

@BasMichielsen BasMichielsen marked this as a duplicate of #92 Feb 11, 2025
@BasMichielsen BasMichielsen marked this as a duplicate of #91 Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants