Someone can have up to 10 scheduled commits waiting. ScheduledCommitLimit checks that while the request is validated, by counting them, and CreateScheduledCommit then stores the new one, with its images processed and kept privately until the due time. Requests sent at the same moment each count before any of them is stored, so they all pass, the same shape as the reaction cap fixed in #1142.
Reproduced locally:
Outstanding scheduled commits
20 PHP processes, each validating then calling the action at the same instant, 5 runs
20 every run
Real HTTP: 9 already scheduled, then 10 POST /scheduled-commits at once (built-in server with 16 workers), 3 runs
11, 12, 12
Over HTTP the overshoot is bounded by the 10-commits-a-minute budget, but it repeats each minute, and every extra slot can hold three stored images.
The fix
Inside its transaction, CreateScheduledCommit locks the user's row, counts the outstanding scheduled commits again, and throws ScheduledCommitLimitReached when the queue is full, before any image is processed or stored. The count and the limit live on ScheduledCommitLimit (outstanding(), MAX, MESSAGE), so the request and the action can't drift apart.
The controllers answer it the way they answer GuildPaused:
Web: back with the same scheduled_at error the request's own check gives.
API: a new scheduled_commit_limit_reached error code (422), with the same message.
Tests
Web and API: keeps the cap when commits scheduled at the same moment all passed the check. Nine are scheduled, the request passes its check, then another commit is scheduled right before the action runs (beforeResolving, as the paused-guild test does). The request is refused with the usual message, ten remain, and on the web no image file is left behind. Both fail on production.
Same runs as above with the fix: 10 every time (20 processes, 5 runs; HTTP, 3 runs).
pint, rector, phpstan: clean. Full suite with --coverage --exactly=100.0: 6454 passed, 100%. Type coverage: 100%.
Summary by CodeRabbit
Bug Fixes
Scheduling now reliably enforces the 10-item limit, including when requests happen concurrently.
Requests that exceed the limit receive a clear error, and uploaded images are not retained when scheduling is rejected.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
coderabbitai[bot]13d ago
No actionable comments were generated in the recent review.
Walkthrough
Scheduled-commit creation now rechecks the user’s outstanding commit count inside a transaction. If the count reaches the limit, the action rejects creation, and the API and web controllers return limit errors.
Changes: Scheduled commit cap
Layer / File(s)
Summary
Count and enforce the cap app/Rules/ScheduledCommitLimit.php, app/Actions/CreateScheduledCommit.php, app/Exceptions/ScheduledCommitLimitReached.php
The rule provides the limit, message, and outstanding count. The action locks the user row and checks the count inside the transaction before creating the scheduled commit.
Return limit errors and test concurrent scheduling app/Enums/ApiErrorCode.php, app/Exceptions/ApiException.php, app/Http/Controllers/Api/ScheduledCommitController.php, app/Http/Controllers/ScheduledCommitController.php, tests/Feature/Controllers/Api/ScheduledCommitControllerTest.php, tests/Feature/ScheduledCommitsTest.php
The API controller returns a 422 error, and the web controller returns a scheduled_at validation error when the limit exception occurs. Tests verify that a concurrent attempt does not exceed the cap and that the uploaded image is not retained.
This change closes a race that allowed more than ten outstanding scheduled commits and returns consistent limit errors from the web and API paths. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the scheduled commit cap is kept when commits are scheduled at the same moment. The summary describes a transactional recheck of the outstanding count after locking th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the scheduled commit cap is kept when commits are scheduled at the same moment. The summary describes a transactional recheck of the outstanding count after locking the user row, which prevents concurrent requests from exceeding the limit of 10. The fix: prefix matches the bug-fix nature of the change.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 70f062f7-89b7-4ec8-a0b7-f7cad2f8edc4
Commits
Reviewing files that changed from the base of the PR and between 1aa85cf4d7c678b3ae7ccf192ab701006d7c2f69 and 888f1f202e4cae8fad08b30a55d74126be972ff2.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.