Skip to content

Commit 732d9eb

Browse files
chriscarrollsmithrafizamankhancursoragent
authored
Propagate main to modal (#184)
* chore: release v0.1.19 [skip ci] * fix bug/new-role-close-dialog-box * ruff format and flaky test fix * Fix ruff and pytest failures * Resolve ty type checking diagnostics * chore: release v0.1.20 [skip ci] * fix create role modal form reset * chore: release v0.1.21 [skip ci] * fix confirm password mismatch (#183) --------- Co-authored-by: Rafiuzzaman Khan <rafiuzzamank@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c8d9ee2 commit 732d9eb

50 files changed

Lines changed: 3792 additions & 2470 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: ruff-format
5+
name: ruff format --check
6+
entry: uv run ruff format --check
7+
language: system
8+
types: [python]
9+
pass_filenames: false
10+
11+
- id: ruff-check
12+
name: ruff check
13+
entry: uv run ruff check
14+
language: system
15+
types: [python]
16+
pass_filenames: false
17+
18+
- id: ty-check
19+
name: ty check
20+
entry: uv run ty check .
21+
language: system
22+
types: [python]
23+
pass_filenames: false

exceptions/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ def __init__(self, user: User, access_token: str, refresh_token: str):
1111
# Define custom exception for email sending failure
1212
class EmailSendFailedError(Exception):
1313
"""Custom exception for email sending failures."""
14-
pass
14+
15+
pass

exceptions/http_exceptions.py

Lines changed: 48 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,86 @@
11
from fastapi import HTTPException, status
22

3+
34
class RateLimitError(HTTPException):
45
"""Raised when a client exceeds the allowed request rate."""
6+
57
def __init__(self, retry_after: int = 60):
68
self.retry_after = retry_after
79
super().__init__(
8-
status_code=429,
9-
detail="Too many attempts. Please try again later."
10+
status_code=429, detail="Too many attempts. Please try again later."
1011
)
1112

1213

1314
class EmailAlreadyRegisteredError(HTTPException):
1415
def __init__(self):
15-
super().__init__(
16-
status_code=409,
17-
detail="This email is already registered"
18-
)
16+
super().__init__(status_code=409, detail="This email is already registered")
1917

2018

2119
class CredentialsError(HTTPException):
2220
def __init__(self, message: str = "Invalid credentials"):
23-
super().__init__(
24-
status_code=401,
25-
detail=message
26-
)
21+
super().__init__(status_code=401, detail=message)
2722

2823

2924
class AuthenticationError(HTTPException):
3025
def __init__(self):
3126
super().__init__(
32-
status_code=status.HTTP_303_SEE_OTHER,
33-
headers={"Location": "/login"}
27+
status_code=status.HTTP_303_SEE_OTHER, headers={"Location": "/login"}
3428
)
3529

3630

3731
class AlreadyAuthenticatedError(HTTPException):
3832
"""Raised when an authenticated user tries to access a page meant for unauthenticated users."""
33+
3934
def __init__(self):
4035
super().__init__(
41-
status_code=status.HTTP_303_SEE_OTHER,
42-
headers={"Location": "/dashboard/"}
36+
status_code=status.HTTP_303_SEE_OTHER, headers={"Location": "/dashboard/"}
4337
)
4438

4539

4640
class PasswordValidationError(HTTPException):
4741
def __init__(self, field: str, message: str):
48-
super().__init__(
49-
status_code=422,
50-
detail={
51-
"field": field,
52-
"message": message
53-
}
54-
)
42+
super().__init__(status_code=422, detail={"field": field, "message": message})
5543

5644

5745
class InsufficientPermissionsError(HTTPException):
5846
def __init__(self):
5947
super().__init__(
60-
status_code=403,
61-
detail="You don't have permission to perform this action"
48+
status_code=403, detail="You don't have permission to perform this action"
6249
)
6350

6451

6552
class OrganizationSetupError(HTTPException):
6653
def __init__(self, message: str = "Organization setup failed"):
67-
super().__init__(
68-
status_code=500,
69-
detail=message
70-
)
54+
super().__init__(status_code=500, detail=message)
7155

7256

7357
class OrganizationNameTakenError(HTTPException):
7458
def __init__(self):
75-
super().__init__(
76-
status_code=400,
77-
detail="Organization name already taken"
78-
)
59+
super().__init__(status_code=400, detail="Organization name already taken")
7960

8061

8162
class OrganizationNotFoundError(HTTPException):
8263
def __init__(self):
83-
super().__init__(
84-
status_code=404,
85-
detail="Organization not found"
86-
)
64+
super().__init__(status_code=404, detail="Organization not found")
8765

8866

8967
class UserNotFoundError(HTTPException):
9068
def __init__(self):
91-
super().__init__(
92-
status_code=404,
93-
detail="User not found"
94-
)
69+
super().__init__(status_code=404, detail="User not found")
9570

9671

9772
class UserAlreadyMemberError(HTTPException):
9873
def __init__(self):
9974
super().__init__(
100-
status_code=400,
101-
detail="User is already a member of this organization"
75+
status_code=400, detail="User is already a member of this organization"
10276
)
10377

10478

10579
class InvalidPermissionError(HTTPException):
10680
"""Raised when a user attempts to assign an invalid permission to a role"""
10781

10882
def __init__(self, permission: str):
109-
super().__init__(
110-
status_code=400,
111-
detail=f"Invalid permission: {permission}"
112-
)
83+
super().__init__(status_code=400, detail=f"Invalid permission: {permission}")
11384

11485

11586
class RoleAlreadyExistsError(HTTPException):
@@ -132,29 +103,26 @@ class RoleHasUsersError(HTTPException):
132103
def __init__(self):
133104
super().__init__(
134105
status_code=400,
135-
detail="Role cannot be deleted until users with that role are reassigned"
106+
detail="Role cannot be deleted until users with that role are reassigned",
136107
)
137108

138109

139110
class CannotModifyDefaultRoleError(HTTPException):
140111
"""Raised when attempting to modify or delete a default system role."""
112+
141113
def __init__(self, action: str = "modify"):
142114
super().__init__(
143-
status_code=403,
144-
detail=f"Default system roles cannot be {action}d."
115+
status_code=403, detail=f"Default system roles cannot be {action}d."
145116
)
146117

147118

148119
class DataIntegrityError(HTTPException):
149-
def __init__(
150-
self,
151-
resource: str = "Database resource"
152-
):
120+
def __init__(self, resource: str = "Database resource"):
153121
super().__init__(
154122
status_code=500,
155123
detail=(
156124
f"{resource} is in a broken state; please contact a system administrator"
157-
)
125+
),
158126
)
159127

160128

@@ -167,93 +135,95 @@ def __init__(self, message: str = "Invalid image file"):
167135

168136
# --- Invitation-specific Errors ---
169137

138+
170139
class UserIsAlreadyMemberError(HTTPException):
171140
"""Raised when trying to invite a user who is already a member of the organization."""
141+
172142
def __init__(self):
173143
super().__init__(
174-
status_code=409,
175-
detail="This user is already a member of the organization."
144+
status_code=409, detail="This user is already a member of the organization."
176145
)
177146

178147

179148
class ActiveInvitationExistsError(HTTPException):
180149
"""Raised when trying to invite a user for whom an active invitation already exists."""
150+
181151
def __init__(self):
182152
super().__init__(
183153
status_code=409,
184-
detail="An active invitation already exists for this email address in this organization."
154+
detail="An active invitation already exists for this email address in this organization.",
185155
)
186156

187157

188158
class InvalidRoleForOrganizationError(HTTPException):
189159
"""Raised when a role provided does not belong to the target organization.
190160
Note: If the role ID simply doesn't exist, a standard 404 RoleNotFoundError should be raised.
191161
"""
162+
192163
def __init__(self):
193164
super().__init__(
194165
status_code=400,
195-
detail="The selected role does not belong to this organization."
166+
detail="The selected role does not belong to this organization.",
196167
)
197168

198169

199170
class InvitationEmailSendError(HTTPException):
200171
"""Raised when the invitation email fails to send."""
172+
201173
def __init__(self):
202174
super().__init__(
203-
status_code=500, # Internal Server Error seems appropriate
204-
detail="Failed to send invitation email. Please try again later or contact support."
175+
status_code=500, # Internal Server Error seems appropriate
176+
detail="Failed to send invitation email. Please try again later or contact support.",
205177
)
206178

207179

208180
class InvalidInvitationTokenError(HTTPException):
209181
"""Raised when an invitation token is invalid, expired, or not found."""
182+
210183
def __init__(self):
211-
super().__init__(
212-
status_code=404,
213-
detail="Invitation not found or expired"
214-
)
184+
super().__init__(status_code=404, detail="Invitation not found or expired")
215185

216186

217187
class InvitationEmailMismatchError(HTTPException):
218188
"""Raised when a user attempts to accept an invitation sent to a different email address."""
189+
219190
def __init__(self):
220191
super().__init__(
221192
status_code=403,
222-
detail="This invitation was sent to a different email address"
193+
detail="This invitation was sent to a different email address",
223194
)
224195

225196

226197
class MaxEmailsReachedError(HTTPException):
227198
"""Raised when an account already has the maximum number of email addresses."""
199+
228200
def __init__(self):
229201
super().__init__(
230-
status_code=400,
231-
detail="Maximum number of email addresses reached"
202+
status_code=400, detail="Maximum number of email addresses reached"
232203
)
233204

234205

235206
class EmailNotVerifiedError(HTTPException):
236207
"""Raised when attempting to promote an unverified email address."""
208+
237209
def __init__(self):
238-
super().__init__(
239-
status_code=400,
240-
detail="Email address is not verified"
241-
)
210+
super().__init__(status_code=400, detail="Email address is not verified")
242211

243212

244213
class CannotRemovePrimaryEmailError(HTTPException):
245214
"""Raised when attempting to remove the primary email address."""
215+
246216
def __init__(self):
247-
super().__init__(
248-
status_code=400,
249-
detail="Cannot remove primary email address"
250-
)
217+
super().__init__(status_code=400, detail="Cannot remove primary email address")
251218

252219

253220
class InvitationProcessingError(HTTPException):
254221
"""Raised when an error occurs during the processing of a valid invitation."""
255-
def __init__(self, detail: str = "Failed to process invitation. Please try again later."):
222+
223+
def __init__(
224+
self, detail: str = "Failed to process invitation. Please try again later."
225+
):
256226
super().__init__(
257-
status_code=500, # Internal Server Error
258-
detail=detail
259-
)
227+
status_code=500, # Internal Server Error
228+
detail=detail,
229+
)

0 commit comments

Comments
 (0)