Skip to content

Conversation

@ArnavBallinCode
Copy link
Contributor

@ArnavBallinCode ArnavBallinCode commented Nov 14, 2025

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:

  • Catch unexpected exceptions during room deletion to avoid uncaught errors and HTTP 500 responses

Enhancements:

  • Log unexpected deletion errors for debugging and display a user-friendly error message
  • Update the success flash message to explicitly state that the selected room has been deleted

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 14, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This 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 handling

sequenceDiagram
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
Loading

File-Level Changes

Change Details Files
Customize room deletion success feedback
  • Replaced generic success phrase with 'The selected room has been deleted.'
app/eventyay/orga/views/schedule.py
Add catch-all exception handling to prevent HTTP 500
  • Introduced an except Exception block wrapping delete logic
  • Logged the exception using logger.exception
  • Presented a formatted user-friendly error message
  • Returned to delete_view on errors
app/eventyay/orga/views/schedule.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1268 Prevent HTTP 500 error when deleting a room in Schedule → Rooms.
#1268 Provide a user-friendly error message if an unexpected error occurs during room deletion.
#1268 Update the room deletion success message to be more descriptive.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArnavBallinCode
Copy link
Contributor Author

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Talk Component: Deleting a room under Schedule returns HTTP 500, but room is actually deleted

1 participant