Skip to content

🐛 Prevent sending empty notifications to webhook#417

Open
septikus wants to merge 1 commit into
juftin:mainfrom
septikus:bugfix/camply-patch
Open

🐛 Prevent sending empty notifications to webhook#417
septikus wants to merge 1 commit into
juftin:mainfrom
septikus:bugfix/camply-patch

Conversation

@septikus

@septikus septikus commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes an issue where empty notifications were still being sent to the webhook listener when no new campsites were found during a search.

Motivation and Context

When running camply in continuous search mode, it periodically checks for campsite availability. If a search completes and finds 0 new campsites (either because nothing was found, or all found sites were already logged), the notification pipeline was still being triggered.

For the webhook provider, this resulted in an empty POST request (containing {"campsites": []}) being sent to the configured WEBHOOK_URL on every single polling interval. This caused unnecessary network traffic and noise for webhook listeners.

Changes

  • camply/search/base_search.py: Added a check (if new_campsites:) to only call _handle_notifications when new campsites are actually discovered.
  • camply/notifications/webhook.py: Added a guard clause in send_campsites to return early if the campsites list is empty, preventing empty POST requests.

Has This Been Tested?

I have added unit tests in tests/test_notifications.py to verify these changes:

  • test_no_notifications_when_no_new_campsites: Verifies that MultiNotifierProvider.send_campsites is not called when _continuous_search_retry finds no new campsites.

  • test_webhook_notifier_empty_campsites: Verifies that WebhookNotifications does not make a POST request when send_campsites is called with an empty list.

    Test Configuration

    • OS: Linux
    • Python Version: 3.13.12
    • Pytest Version: 9.1.1
    • Command run: PUSHOVER_PUSH_USER=dummy PUSHOVER_PUSH_TOKEN=dummy pytest -o addopts="" -W ignore tests/test_notifications.py

    Checklist:

    • I've read the contributing guidelines of this project
    • I've added a BUMP_MAJOR, BUMP_MINOR, or BUMP_PATCH label to this PR to increment the version
    • I've installed and used .pre_commit on all my code
    • I have documented my code, particularly in hard-to-understand areas
    • I have made any necessary corresponding changes to the documentation

@septikus septikus marked this pull request as ready for review June 27, 2026 17:07
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.

1 participant