Fix the internal error that occurs when deleting a project not linked…#659
Merged
vincent-olivert-riera merged 3 commits intoline:masterfrom Oct 16, 2025
Conversation
fa98e21 to
fd1c6f2
Compare
vincent-olivert-riera
requested changes
Oct 15, 2025
Contributor
vincent-olivert-riera
left a comment
There was a problem hiding this comment.
Just a comment. Everything else looks good.
| response = self.client.get(reverse(viewname, kwargs=params)) | ||
| self.assertRoute(response, viewclass, status_code) | ||
|
|
||
| def test_delete_project_without_farm(self): |
Contributor
There was a problem hiding this comment.
Please put the addition of the test in a separate commit (remember to also move the models import you have added for it).
… to any farm After modifying the relationship between Farm and Project to one-to-one, directly accessing a project's farm using "project.farm" might trigger a RelatedObjectDoesNotExist exception, resulting in an internal error in Promgen. To prevent this, we must verify the existence of the farm every time before attempting to access it.
In the past, an error occurred when we forgot to check for the existence of a farm before attempting to access it at the time the delete_project signal was triggered. This caused the project deletion action to throw a RelatedObjectDoesNotExist exception when it tried to access the farm of the project being deleted. As a result, the deletion of the project or its parent service failed, and Promgen Web displayed an Internal Error. We have added a self-test for this case to ensure that the bug has been fixed and will always be checked in the future.
Currently, we are checking the existence of a project's farm before accessing it using this syntax: ``` getattr(project, "farm", None) is not None ``` This can be shortened to: ``` hasattr(project, "farm") ``` We have replaced all instances of the original syntax with the new one.
fd1c6f2 to
e4f3dd5
Compare
vincent-olivert-riera
approved these changes
Oct 16, 2025
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.
… to any farm
After modifying the relationship between Farm and Project to one-to-one, directly accessing a project's farm using "project.farm" might trigger a RelatedObjectDoesNotExist exception, resulting in an internal error in Promgen. To prevent this, we must verify the existence of the farm every time before attempting to access it.