-
Notifications
You must be signed in to change notification settings - Fork 131
( Fix ) HTTP 500 error handling during room deletion #1280
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
base: enext
Are you sure you want to change the base?
( Fix ) HTTP 500 error handling during room deletion #1280
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR enhances the room deletion handler by replacing the generic success message with a more descriptive one and by adding a catch-all exception block to log unexpected errors and display a user-friendly error message instead of returning an HTTP 500. Sequence diagram for improved room deletion error handlingsequenceDiagram
actor User
participant "RoomDeletionHandler"
participant "Logger"
participant "Messages"
User->>"RoomDeletionHandler": Request to delete room
activate "RoomDeletionHandler"
"RoomDeletionHandler"->>"RoomDeletionHandler": get_object()
"RoomDeletionHandler"->>"RoomDeletionHandler": obj.deleted = True
"RoomDeletionHandler"->>"RoomDeletionHandler": obj.save(update_fields=['deleted'])
"RoomDeletionHandler"->>"Messages": success(request, "The selected room has been deleted.")
"RoomDeletionHandler"->>User: Redirect to success URL
Note over "RoomDeletionHandler": If ProtectedError
"RoomDeletionHandler"->>"Messages": error(request, "There is or was a session scheduled in this room. It cannot be deleted.")
"RoomDeletionHandler"->>User: Return delete view
Note over "RoomDeletionHandler": If unexpected Exception
"RoomDeletionHandler"->>"Logger": logger.exception(...)
"RoomDeletionHandler"->>"Messages": error(request, "An error occurred while deleting the room: ...")
"RoomDeletionHandler"->>User: Return delete view
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `app/eventyay/orga/views/schedule.py:523-522` </location>
<code_context>
_('There is or was a session scheduled in this room. It cannot be deleted.'),
)
return self.delete_view(request, *args, **kwargs)
+ except Exception as e:
+ messages.error(
+ request,
+ _('An error occurred while deleting the room: {}').format(str(e)),
+ )
+ return self.delete_view(request, *args, **kwargs)
</code_context>
<issue_to_address>
**issue (bug_risk):** Catching all exceptions may mask unexpected errors.
Consider catching only specific exceptions or logging the error before handling, to improve troubleshooting and avoid hiding critical issues.
</issue_to_address>
### Comment 2
<location> `app/eventyay/orga/views/schedule.py:518` </location>
<code_context>
+ messages.success(request, _('The selected room has been deleted.'))
return redirect(self.get_success_url())
except ProtectedError:
messages.error(
</code_context>
<issue_to_address>
**🚨 issue (security):** Exposing raw exception messages to users may leak sensitive information.
Log the exception details internally and present a generic error message to users instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `app/eventyay/orga/views/schedule.py:518` </location>
<code_context>
+ messages.success(request, _('The selected room has been deleted.'))
return redirect(self.get_success_url())
except ProtectedError:
messages.error(
</code_context>
<issue_to_address>
**🚨 issue (security):** Displaying raw exception messages to users may expose sensitive information.
Display a user-friendly error message and log exception details internally to avoid exposing sensitive information.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Fixes #1268
Screen.Recording.2025-11-15.at.12.30.38.AM.mov
Summary by Sourcery
Add robust error handling for room deletion to prevent HTTP 500 errors and improve user feedback
Bug Fixes:
Enhancements: