Skip to content

fix(tasks): handle GitHub app rate limits and improve notification debouncing#625

Open
seer-by-sentry[bot] wants to merge 1 commit intomainfrom
seer/fix/bundle-analysis-app-rate-limit-retry
Open

fix(tasks): handle GitHub app rate limits and improve notification debouncing#625
seer-by-sentry[bot] wants to merge 1 commit intomainfrom
seer/fix/bundle-analysis-app-rate-limit-retry

Conversation

@seer-by-sentry
Copy link
Contributor

@seer-by-sentry seer-by-sentry bot commented Dec 19, 2025

Fixes WORKER-WJ5

Also addresses:

  • WORKER-WJ8 - "Not retrying lock acquisition - max retries exceeded"
  • WORKER-WJA - LockNotOwnedError from lock timeout
  • WORKER-WJ4 - LockError in BundleAnalysisProcessor
  • WORKER-WJ3 - Bundle analysis processor exceeded max retries

Summary

The core issue was that persistent NoConfiguredAppsAvailable errors prevented repository service calls, causing tasks to exhaust lock retries and fail. This PR:

  1. Adds notification debouncing - New NotificationDebouncer with Redis fencing tokens to coalesce concurrent notifications
  2. Improves lock handling - Standardized lock acquisition via notification_lock, new LockAcquisitionLimitError, and handle_lock_retry helper
  3. Handles GitHub app rate limits - Tasks now use earliest_retry_after_seconds from the exception or fall back to get_seconds_to_next_hour
  4. Adds checkpoints - NOTIF_LOCK_ERROR added to TestResultsFlow for observability

Changes

  • Added handling for the NoConfiguredAppsAvailable exception in BundleAnalysisProcessorTask
  • If GitHub apps are rate-limited, tasks schedule a retry with appropriate delay
  • If no configured GitHub apps are available or all are suspended, tasks skip processing gracefully
  • Renamed LockRetryLimitExceededError to LockAcquisitionLimitError for clarity

This fix was generated by Seer in Sentry, triggered by Joe Becher. 👁️ Run ID: 7765586

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Note

Introduces Redis-based notification debouncing and unified lock/retry handling across worker tasks, plus improved GitHub App rate-limit backoff.

  • Add NotificationDebouncer with fencing tokens (SKIP_DEBOUNCE_TOKEN) and notification_lock; integrate into notify, test_analytics_notifier, and bundle_analysis_notify to coalesce concurrent runs and exit when tokens are stale
  • Standardize lock error handling via handle_lock_retry and new LockAcquisitionLimitError; log NOTIF_LOCK_ERROR in UploadFlow/TestResultsFlow; BaseCodecovTask now catches lock-acquisition limits and factors DB-retry logic into _handle_database_error_retry
  • Respect GitHub App rate limits using earliest_retry_after_seconds when present; otherwise fall back to get_seconds_to_next_hour; apply in base/notify/bundle-analysis processor
  • Enhance shared GitHub App selection: partition apps by rate-limit status, compute earliest TTL (_get_earliest_rate_limit_ttl), and surface it via NoConfiguredAppsAvailable
  • Numerous unit/integration tests added for debouncing, lock retries, rate-limit backoff, and bundle analysis paths

Written by Cursor Bugbot for commit 5cba3e8. This will update automatically on new commits. Configure here.

@sentry
Copy link

sentry bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 83.84615% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.36%. Comparing base (6e3603b) to head (5cba3e8).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/tasks/notify.py 70.37% 16 Missing ⚠️
apps/worker/tasks/base.py 56.52% 10 Missing ⚠️
apps/worker/tasks/bundle_analysis_processor.py 23.07% 10 Missing ⚠️
apps/worker/tasks/test_analytics_notifier.py 91.66% 4 Missing ⚠️
apps/worker/services/notification/debounce.py 97.72% 1 Missing ⚠️
apps/worker/tasks/bundle_analysis_notify.py 97.61% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #625    +/-   ##
========================================
  Coverage   93.35%   93.36%            
========================================
  Files        1292     1293     +1     
  Lines       47128    47281   +153     
  Branches     1567     1573     +6     
========================================
+ Hits        43996    44143   +147     
- Misses       2823     2829     +6     
  Partials      309      309            
Flag Coverage Δ
apiunit 96.55% <ø> (ø)
sharedintegration 38.00% <11.42%> (-0.07%) ⬇️
sharedunit 87.12% <100.00%> (+0.01%) ⬆️
workerintegration 59.10% <43.11%> (-0.04%) ⬇️
workerunit 91.34% <81.33%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

codecov-notifications bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 83.84615% with 42 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/tasks/notify.py 70.37% 16 Missing ⚠️
apps/worker/tasks/base.py 56.52% 10 Missing ⚠️
apps/worker/tasks/bundle_analysis_processor.py 23.07% 10 Missing ⚠️
apps/worker/tasks/test_analytics_notifier.py 91.66% 4 Missing ⚠️
apps/worker/services/notification/debounce.py 97.72% 1 Missing ⚠️
apps/worker/tasks/bundle_analysis_notify.py 97.61% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@drazisil-codecov drazisil-codecov requested a review from a team December 19, 2025 18:37
@drazisil-codecov drazisil-codecov marked this pull request as ready for review December 19, 2025 18:41
@drazisil-codecov
Copy link
Contributor

@sentry review

Comment on lines 468 to 476
except MaxRetriesExceededError:
# Log checkpoint if flows have begun
if UploadFlow.has_begun():
UploadFlow.log(UploadFlow.UNCAUGHT_RETRY_EXCEPTION)
if TestResultsFlow.has_begun():
TestResultsFlow.log(TestResultsFlow.UNCAUGHT_RETRY_EXCEPTION)
# Return None to indicate task failure after max retries exceeded
return None
except LockRetryLimitExceededError:
Copy link
Contributor

Choose a reason for hiding this comment

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

I am absolutely not happy with these two exceptions being named so similar, but they have different purposes and can't be combined, since one is from Celery.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 22, 2025

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing seer/fix/bundle-analysis-app-rate-limit-retry (5cba3e8) with main (b75c63d)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (5ea839e) during the generation of this report, so b75c63d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@drazisil-codecov drazisil-codecov requested a review from a team January 16, 2026 16:13
@drazisil-codecov drazisil-codecov force-pushed the seer/fix/bundle-analysis-app-rate-limit-retry branch from 8a412bd to 53e7e2d Compare January 16, 2026 16:19
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

…bouncing

Add notification debouncing with Redis fencing tokens and improve lock handling
across notification tasks. Handle GitHub app rate limits by retrying with
appropriate delays from the API response.

Changes:
- Add NotificationDebouncer with fencing tokens to coalesce concurrent notifications
- Standardize lock acquisition via notification_lock helper
- Add LockAcquisitionLimitError and handle_lock_retry for consistent retry handling
- Handle NoConfiguredAppsAvailable in BundleAnalysisProcessorTask
- Use earliest_retry_after_seconds from exception or fall back to next hour
- Add NOTIF_LOCK_ERROR checkpoint to TestResultsFlow for observability
- Add _partition_apps_by_rate_limit_status for improved rate limit handling

Fixes:
- WORKER-WJ5 - NoConfiguredAppsAvailable in bundle analysis
- WORKER-WJ8 - "Not retrying lock acquisition - max retries exceeded"
- WORKER-WJA - LockNotOwnedError from lock timeout
- WORKER-WJ4 - LockError in BundleAnalysisProcessor
- WORKER-WJ3 - Bundle analysis processor exceeded max retries
@drazisil-codecov drazisil-codecov force-pushed the seer/fix/bundle-analysis-app-rate-limit-retry branch from 53e7e2d to 5cba3e8 Compare January 16, 2026 17:20
@drazisil-codecov drazisil-codecov changed the title fix(tasks): Handle GitHub app rate limits in bundle analysis processor fix(tasks): handle GitHub app rate limits and improve notification debouncing Jan 16, 2026
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