Skip to content

Update project creation limits#20046

Draft
JacobCoffee wants to merge 13 commits into
mainfrom
limit-projects
Draft

Update project creation limits#20046
JacobCoffee wants to merge 13 commits into
mainfrom
limit-projects

Conversation

@JacobCoffee
Copy link
Copy Markdown
Member

No description provided.

Comment thread warehouse/config.py Outdated
"warehouse.packaging.project_create_user_ratelimit_string",
"PROJECT_CREATE_USER_RATELIMIT_STRING",
default="20 per hour",
default="2 per day",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this will make testpypi angry and is set in cabo via PROJECT_CREATE_USER_RATELIMIT_STRING so

Comment thread tests/unit/packaging/test_services.py Outdated
_check_ratelimits now runs on every create_project call, which
evaluates creator.id to pass to the limiter. The bare pretend.stub()
has no id attribute, so the test blew up before reaching the
AdminFlag-forbidden path it was meant to exercise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JacobCoffee JacobCoffee marked this pull request as ready for review May 8, 2026 16:15
@JacobCoffee JacobCoffee requested a review from a team as a code owner May 8, 2026 16:15
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd28ee59d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 881 to 884
self.request.user,
request=self.request,
creator_is_owner=False,
ratelimited=False,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Catch project rate-limit errors when adding org projects

This call now goes through ProjectService.create_project() with rate limiting enabled, but this view still only catches HTTPException. When a user has exceeded project.create.* limits, create_project() raises TooManyProjectsCreated (a RateLimiterException, not an HTTPException), so the exception escapes and turns a normal validation failure into a 500 for organization project creation attempts.

Useful? React with 👍 / 👎.

Comment thread warehouse/oidc/views.py
Comment on lines 225 to 229
pending_publisher.added_by,
request,
creator_is_owner=pending_publisher.organization_id is None,
ratelimited=False,
organization_id=pending_publisher.organization_id,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Catch project rate-limit errors in pending publisher minting

Pending-publisher token minting now invokes rate-limited project creation, but this block only handles HTTPException. If the pending publisher owner has hit project creation limits, create_project() raises TooManyProjectsCreated (not an HTTPException), which is unhandled here and results in a server error instead of a structured API error response.

Useful? React with 👍 / 👎.

JacobCoffee and others added 3 commits May 8, 2026 11:23
…tion

Adds regression coverage for the two view-layer catches added in
41a6bd1 / a162387 — confirms that hitting the per-user
project-create ratelimiter while creating an org-owned project or
reifying a pending OIDC publisher returns a structured error
(form-error / 422 JSON) instead of a 500.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JacobCoffee JacobCoffee marked this pull request as draft May 8, 2026 16:33
JacobCoffee and others added 4 commits May 8, 2026 11:40
Parametrize the new TooManyProjectsCreated regression tests so they
exercise both a real timedelta and the resets_in=None branch the
defensive handlers in oidc/views.py and manage/views/organizations.py
fall back to. None can legitimately come back from the limiter on a
race or a transient redis error, and we want a 429 with "try again
later" instead of a 500.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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