Skip to content

Avoid rate limits in reseed-auth0 cron job - #840

Merged
pylipp merged 2 commits into
masterfrom
avoid-auth0-429-when-reseeding
Sep 10, 2026
Merged

Avoid rate limits in reseed-auth0 cron job#840
pylipp merged 2 commits into
masterfrom
avoid-auth0-429-when-reseeding

Conversation

@pylipp

@pylipp pylipp commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Auth0 throttling remains insufficient, and pacing holds the database transaction open.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates Auth0 reseeding with API throttling, additional seed data, and documentation changes.

Changes:

  • Adds delays around Auth0 Management API calls.
  • Adds organization and camp/base seed data.
  • Updates reseeding instructions.
File summaries
File Summary
README.md Updates instructions; remaining documentation path and port inconsistencies need correction.
library/lib/auth0.php Adds delays, but the 200 ms interval does not sufficiently limit all API calls.
db/init.sql Adds organization and camp/base seed records.
cron/reseed-auth0.php Adds role-sync delays, but pacing is too fast and occurs inside the database transaction.
Review details

Suppressed comments (3)

README.md:60

  • The canonical README path was corrected to /cron/reseed-auth0.php, but docs/auth0.md:62 still directs users to /reseed-auth0.php; gcloud-entry.php only routes the former and returns 404 for the latter. Please update the remaining Auth0 reseeding documentation in the same change.
6.  If you want to connect new bases and organisations from the seed to Auth0 and populate the `cms_*` db tables, open a browser and request `http://localhost:8100/cron/reseed-auth0.php` (`init.sql` must contain the new bases)

README.md:60

  • The PHP development-server setup documented above runs on port 8000, but this instruction hardcodes Docker's port 8100. Following the non-Docker setup therefore sends the reseed request to the wrong server; document both URLs or make the host/port depend on the selected setup.
6.  If you want to connect new bases and organisations from the seed to Auth0 and populate the `cms_*` db tables, open a browser and request `http://localhost:8100/cron/reseed-auth0.php` (`init.sql` must contain the new bases)

cron/reseed-auth0.php:38

  • This delay runs inside the transaction opened at db_transaction on line 18. By this point the reseed has inserted/updated CMS role rows, so each 200 ms pause keeps those locks open until the entire Auth0 user sync finishes; a full run can therefore block concurrent role/group changes. Please avoid holding the database transaction while pacing the remote API, or split the database and Auth0 phases.
        usleep(200000);
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread cron/reseed-auth0.php
while ($row = db_fetch($result)) {
$role = getRolesByName($row['auth0_role_name']);
db_query('UPDATE cms_usergroups_roles SET auth0_role_id = :id WHERE auth0_role_name = :rolename', ['id' => $role['id'], 'rolename' => $row['auth0_role_name']]);
usleep(200000);
Comment thread library/lib/auth0.php
}

$response = $mgmtAPI->users()->update($auth0UserId, $auth0UserData);
usleep(200000);
@pylipp
pylipp merged commit 26027e0 into master Sep 10, 2026
7 checks passed
@pylipp
pylipp deleted the avoid-auth0-429-when-reseeding branch September 10, 2026 22:33
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.

2 participants