Skip to content

Conversation

@ArnavBallinCode
Copy link
Contributor

@ArnavBallinCode ArnavBallinCode commented Nov 15, 2025

Fix Speaker Acceptance Confirmation Link Returning 500 Error

The SubmissionConfirmView.dispatch() method tried to access self.submission (a cached property) before calling super().dispatch(), which caused an AttributeError because self.request and self.kwargs weren't initialized yet.

Modified dispatch() to manually initialize self.request, self.args, and self.kwargs before accessing self.submission:

def dispatch(self, request, *args, **kwargs):
    if request.user.is_anonymous:
        return get_login_redirect(request)
    
    # Initialize request attributes before accessing self.submission
    self.request = request
    self.args = args
    self.kwargs = kwargs
    
    if not request.user.has_perm('base.is_speaker_submission', self.submission):
        self.template_name = 'cfp/event/user_submission_confirm_error.html'
    return super().dispatch(request, *args, **kwargs)

Fixes #1276

Summary by Sourcery

Bug Fixes:

  • Initialize request, args, and kwargs in SubmissionConfirmView.dispatch before accessing self.submission to prevent AttributeError and 500 error on confirmation link

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR patches the SubmissionConfirmView.dispatch method to manually initialize the view’s request context (request, args, kwargs) before accessing the cached submission, preventing an AttributeError and subsequent 500 error when loading the confirmation link.

Sequence diagram for speaker submission confirmation link access

sequenceDiagram
actor User
participant "SubmissionConfirmView"
participant "get_login_redirect()"
participant "super().dispatch()"
User->>"SubmissionConfirmView": GET /event/me/submissions/CODE/confirm
alt User is anonymous
    "SubmissionConfirmView"->>"get_login_redirect()": Redirect to login
    "get_login_redirect()"-->>User: 302 Found (redirect to login)
else User is authenticated
    "SubmissionConfirmView"->>"SubmissionConfirmView": Initialize request, args, kwargs
    "SubmissionConfirmView"->>"SubmissionConfirmView": Check user permission on submission
    alt User lacks permission
        "SubmissionConfirmView"->>"SubmissionConfirmView": Set error template
    end
    "SubmissionConfirmView"->>"super().dispatch()": Continue dispatch
end
Loading

File-Level Changes

Change Details Files
Ensure dispatch initializes instance context before accessing submission
  • assign self.request = request
  • assign self.args = args
  • assign self.kwargs = kwargs
app/eventyay/cfp/views/user.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1276 Fix the 'Confirm your attendance' link in the speaker acceptance email so that it does not result in a 500 Internal Server Error when accessed.
#1276 Ensure that the 'Confirm your attendance' link allows the speaker to successfully confirm their participation (i.e., the confirmation page loads and functions as intended).

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 - here's some feedback:

  • Replace manual assignment of self.request, self.args, and self.kwargs with a call to self.setup(request, *args, **kwargs) at the start of dispatch to align with Django CBV conventions.
  • Consider using Django's built-in LoginRequiredMixin and PermissionRequiredMixin for cleaner authentication and authorization handling instead of custom checks in dispatch.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Replace manual assignment of self.request, self.args, and self.kwargs with a call to self.setup(request, *args, **kwargs) at the start of dispatch to align with Django CBV conventions.
- Consider using Django's built-in LoginRequiredMixin and PermissionRequiredMixin for cleaner authentication and authorization handling instead of custom checks in dispatch.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the speaker acceptance confirmation link was returning a 500 error due to an AttributeError. The issue occurred because SubmissionConfirmView.dispatch() tried to access self.submission (a cached property that depends on self.request and self.kwargs) before these attributes were initialized by the parent class's dispatch() method.

The fix manually initializes self.request, self.args, and self.kwargs before accessing self.submission, preventing the AttributeError.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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: Speaker Acceptance Email Contains Broken Link (Error 500)

1 participant