Skip to content

Fix cross-project bot throttling and event cleanup - #2593

Open
landong-coder wants to merge 3 commits into
exceptionless:mainfrom
landong-coder:issue/project-scoped-bot-throttling
Open

landong-coder wants to merge 3 commits into
exceptionless:mainfrom
landong-coder:issue/project-scoped-bot-throttling

Conversation

@landong-coder

@landong-coder landong-coder commented Sep 21, 2026 •

Copy link
Copy Markdown

Bot throttling currently shares an IP/time-window counter across projects and organizations. Its cleanup job also deletes matching events across the entire organization, so one project's traffic can throttle another project or remove events from a project with bot filtering disabled.

Scope counters and batch grouping by organization, project, and client IP. Cache keys use Organization:{organizationId}:Project:{projectId}:bot:{period}:{ip} through a dedicated helper. Cleanup calls RemoveAllByProjectAndClientIpAsync; organization-wide retention cleanup calls RemoveAllByOrganizationAndClientIpAsync. Interface declarations, implementations, callers, and tests use these explicit scope names. Invalid cleanup tasks fail before deletion.

Tests and validation

  • Rebased onto upstream main at 7e1c4e9ad.
  • Test project builds; eight focused unit tests pass on the latest revision.
  • Plugin tests use the existing TestWithLoggingBase, its logger factory, and asynchronous disposal.
  • Four repository integration cases cover actual deletion boundaries across projects, organizations, IPs, and optional date ranges. Their names and calls were updated for the explicit repository methods.
  • Local integration execution remains blocked at Aspire fixture initialization because Docker is unavailable; deletion assertions have not run locally.
  • git diff --check passed.

Compatibility and deployment

Repository interface breaking change: the organization-scoped RemoveAllAsync overload is renamed to RemoveAllByOrganizationAndClientIpAsync, as requested in review. External source callers or custom IEventRepository implementations using that overload must update and rebuild. The project-scoped method introduced in this PR is named RemoveAllByProjectAndClientIpAsync. Existing generic repository deletion APIs remain unchanged. No HTTP API, configuration-key, or work-item payload changes.

The new cache keys start fresh per-project counters; old shared keys expire naturally. Update all event-processing and cleanup worker instances together. Existing queued tasks with valid project IDs remain supported; invalid tasks fail before deletion.

@CLAassistant

CLAassistant commented Sep 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@niemyjski niemyjski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a ton for your pr, these changes would really help a lot and we really appreciate it. I left a few comments which I feel would really help testing and debugging this in production scenarios.

Comment thread src/Exceptionless.Core/Jobs/WorkItemHandlers/RemoveBotEventsWorkItemHandler.cs Outdated
Comment thread src/Exceptionless.Core/Plugins/EventProcessor/Default/0_ThrottleBotsPlugin.cs Outdated
Comment thread tests/Exceptionless.Tests/Plugins/ThrottleBotsPluginTests.cs Outdated
@landong-coder
landong-coder force-pushed the issue/project-scoped-bot-throttling branch from 6f0dc6c to c908242 Compare September 22, 2026 02:25
Comment thread src/Exceptionless.Core/Repositories/Interfaces/IEventRepository.cs Outdated
@landong-coder
landong-coder force-pushed the issue/project-scoped-bot-throttling branch from c908242 to 3f173c0 Compare September 24, 2026 02:22

This branch has not been deployed

No deployments
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.

4 participants