Skip to content

fix: notify_webhooks break instead of continue#3396

Open
Manishnemade12 wants to merge 7 commits intofossasia:devfrom
Manishnemade12:fix/notify-webhooks-break-instead-of-continue
Open

fix: notify_webhooks break instead of continue#3396
Manishnemade12 wants to merge 7 commits intofossasia:devfrom
Manishnemade12:fix/notify-webhooks-break-instead-of-continue

Conversation

@Manishnemade12
Copy link
Copy Markdown
Contributor

@Manishnemade12 Manishnemade12 commented Apr 26, 2026

Description

Closes : #3400

  • Replace break with continue in notify_webhooks Celery task when a log entry lacks an organizer or a matching webhook_type
  • Add logger.debug statements when skipping these entries
  • Using break caused the entire batch of log entries to be silently dropped if any single entry in the batch triggered these conditions

Summary by Sourcery

Ensure webhook notification processing skips invalid log entries instead of aborting the entire batch.

Bug Fixes:

  • Prevent notify_webhooks from dropping the remaining batch when encountering log entries without an organizer or webhook type by skipping those entries instead.

Enhancements:

  • Add debug logging when webhook notifications are skipped due to missing organizer or webhook type information.

- Replace break with continue in notify_webhooks Celery task when a log
  entry lacks an organizer or a matching webhook_type
- Add logger.debug statements when skipping these entries
- Using break caused the entire batch of log entries to be silently
  dropped if any single entry in the batch triggered these conditions
Copilot AI review requested due to automatic review settings April 26, 2026 10:52
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the notify_webhooks Celery task so that invalid log entries are skipped rather than aborting the entire batch, and adds debug logging to make skipped entries observable.

Sequence diagram for notify_webhooks batch processing with skipping invalid log entries

sequenceDiagram
    participant CeleryWorker
    participant WebhookNotifier
    participant LogEntry
    participant OrganizerWebhooks
    participant Logger

    CeleryWorker->>WebhookNotifier: notify_webhooks(logentry_ids)
    WebhookNotifier->>WebhookNotifier: load queryset qs from logentry_ids

    loop for each logentry in qs
        WebhookNotifier->>LogEntry: read organizer
        alt organizer is missing
            WebhookNotifier->>Logger: debug(Skipping: no organizer)
            WebhookNotifier-->>WebhookNotifier: continue to next logentry
        else organizer present
            WebhookNotifier->>LogEntry: read webhook_type
            alt webhook_type is missing
                WebhookNotifier->>Logger: debug(Skipping: no matching webhook event type)
                WebhookNotifier-->>WebhookNotifier: continue to next logentry
            else webhook_type present
                WebhookNotifier->>OrganizerWebhooks: fetch webhooks for organizer and action_type
                OrganizerWebhooks-->>WebhookNotifier: webhooks list
                WebhookNotifier->>OrganizerWebhooks: send_notifications(webhooks, logentry)
            end
        end
    end

    WebhookNotifier-->>CeleryWorker: return after processing all logentries
Loading

Flow diagram for notify_webhooks log entry filtering and processing

flowchart TD
    A[Start notify_webhooks
logentry_ids] --> B[Load queryset qs]
    B --> C{More logentries?}
    C -->|No| Z[End task]
    C -->|Yes| D[Get next logentry]

    D --> E{logentry.organizer exists?}
    E -->|No| E1[logger.debug
Skipping: no organizer]
    E1 --> C
    E -->|Yes| F{logentry.webhook_type exists?}

    F -->|No| F1[logger.debug
Skipping: no matching webhook event type]
    F1 --> C

    F -->|Yes| G[Check cached
_org, _at, webhooks]
    G --> H[Fetch or reuse
webhooks for organizer
and action_type]
    H --> I[Send webhook
notifications]
    I --> C
Loading

File-Level Changes

Change Details Files
Skip invalid log entries in notify_webhooks instead of aborting the entire batch, and add debug logging for skipped entries.
  • Change control flow so that log entries without an organizer are skipped with continue instead of terminating the loop
  • Change control flow so that log entries without a webhook_type are skipped with continue instead of terminating the loop
  • Add logger.debug statements to record when a log entry is skipped due to missing organizer or missing webhook event type
app/eventyay/api/webhooks.py

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
Copy Markdown
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 - I've left some high level feedback:

  • Consider including additional context (e.g., organizer ID or event ID) in the debug messages so that skipped log entries can be traced more easily during debugging.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider including additional context (e.g., organizer ID or event ID) in the debug messages so that skipped log entries can be traced more easily during debugging.

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
Copy Markdown
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

Fixes webhook notification batching so that individual malformed/unhandled log entries no longer stop processing of the remaining entries in the same Celery task run.

Changes:

  • Replace break with continue in notify_webhooks when a LogEntry has no organizer.
  • Replace break with continue in notify_webhooks when a LogEntry has no matching webhook_type.
  • Add logger.debug messages when entries are skipped for these reasons.

Comment thread app/eventyay/api/webhooks.py
Copilot AI review requested due to automatic review settings April 27, 2026 03:54
Copy link
Copy Markdown
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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread app/tests/tickets/base/test_webhooks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 13:35
Copy link
Copy Markdown
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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread app/tests/tickets/base/test_webhooks.py Outdated
Copilot AI review requested due to automatic review settings May 2, 2026 11:04
Copy link
Copy Markdown
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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines 269 to +274
if not logentry.organizer:
break # We need to know the organizer
logger.debug(
'Skipping webhook notification for log entry %d: no organizer',
logentry.id,
)
continue # We need to know the organizer, skip this entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

notify_webhooks Uses break Instead of continue, Silently Dropping Webhook Notifications

2 participants