-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update project creation limits #20046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
606e2be
2a0cc2d
dcf060d
00f028a
51a5956
fd28ee5
41a6bd1
a162387
38ae2e7
4146bd4
fb9633b
91a23fc
ee55d98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ | |
| OIDC_ISSUER_SERVICE_NAMES, | ||
| lookup_custom_issuer_type, | ||
| ) | ||
| from warehouse.packaging.interfaces import IProjectService | ||
| from warehouse.packaging.interfaces import IProjectService, TooManyProjectsCreated | ||
| from warehouse.packaging.models import ProjectFactory | ||
| from warehouse.rate_limiting.interfaces import IRateLimiter | ||
|
|
||
|
|
@@ -225,14 +225,28 @@ def mint_token( | |
| pending_publisher.added_by, | ||
| request, | ||
| creator_is_owner=pending_publisher.organization_id is None, | ||
| ratelimited=False, | ||
| organization_id=pending_publisher.organization_id, | ||
| ) | ||
|
Comment on lines
225
to
229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Pending-publisher token minting now invokes rate-limited project creation, but this block only handles Useful? React with 👍 / 👎. |
||
| except HTTPException as exc: | ||
| return _invalid( | ||
| errors=[{"code": "invalid-payload", "description": str(exc)}], | ||
| request=request, | ||
| ) | ||
| except TooManyProjectsCreated as exc: | ||
| retry = ( | ||
| f"Try again in {int(exc.resets_in.total_seconds())} seconds." | ||
| if exc.resets_in is not None | ||
| else "Try again later." | ||
| ) | ||
| return _invalid( | ||
| errors=[ | ||
| { | ||
| "code": "too-many-projects", | ||
| "description": f"Too many new projects created. {retry}", | ||
| } | ||
| ], | ||
| request=request, | ||
| ) | ||
|
|
||
| # Reify the pending publisher against the newly created project | ||
| reified_publisher = oidc_service.reify_pending_publisher( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call now goes through
ProjectService.create_project()with rate limiting enabled, but this view still only catchesHTTPException. When a user has exceededproject.create.*limits,create_project()raisesTooManyProjectsCreated(aRateLimiterException, not anHTTPException), so the exception escapes and turns a normal validation failure into a 500 for organization project creation attempts.Useful? React with 👍 / 👎.