Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unit/packaging/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def test_check_project_test_new_disallowed(self, db_request):
service = ProjectService(session=db_request.db)

with pytest.raises(HTTPForbidden) as exc:
service.create_project("foo", pretend.stub(), db_request, ratelimited=False)
service.create_project("foo", pretend.stub(), db_request)
Comment thread
JacobCoffee marked this conversation as resolved.
Outdated

resp = exc.value
assert resp.status_code == 403
Expand Down
30 changes: 15 additions & 15 deletions warehouse/locale/messages.pot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion warehouse/manage/views/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ def add_organization_project(self):
self.request.user,
request=self.request,
creator_is_owner=False,
ratelimited=False,
)
Comment on lines 882 to 885
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 👍 / 👎.

except HTTPException as exc:
form.new_project_name.errors.append(exc.detail)
Expand Down
1 change: 0 additions & 1 deletion warehouse/oidc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ 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
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 👍 / 👎.

except HTTPException as exc:
Expand Down
7 changes: 2 additions & 5 deletions warehouse/packaging/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,9 @@ def create_project(
request,
*,
creator_is_owner=True,
ratelimited=True,
organization_id=None,
):
if ratelimited:
self._check_ratelimits(request, creator)
self._check_ratelimits(request, creator)

# Check for AdminFlag set by a PyPI Administrator disabling new project
# registration, reasons for this include Spammers, security
Expand Down Expand Up @@ -716,8 +714,7 @@ def create_project(
)
request.db.delete(stale_publisher)

if ratelimited:
self._hit_ratelimits(request, creator)
self._hit_ratelimits(request, creator)
return project


Expand Down
Loading