kamau1 commited on
Commit
e6976da
Β·
1 Parent(s): 23ef24c

fix: Remove project status restrictions for invitations

Browse files

- Removed validation requiring projects to be in 'draft' or 'planning' status
- Users can now be invited/imported to projects in any status (draft, planning, active, etc.)
- Removed status check from both invitation creation and auto-add to team
- Fixes 400 Bad Request error when inviting users to active projects

docs/devlogs/server/runtimeerror.txt CHANGED
@@ -1,32 +1,33 @@
1
- ===== Application Startup at 2025-11-24 09:08:33 =====
2
 
3
- INFO: 2025-11-24T09:08:47 - app.main: ============================================================
4
- INFO: 2025-11-24T09:08:47 - app.main: πŸš€ SwiftOps API v1.0.0 | PRODUCTION
5
- INFO: 2025-11-24T09:08:47 - app.main: πŸ“Š Dashboard: Enabled
6
- INFO: 2025-11-24T09:08:47 - app.main: ============================================================
7
- INFO: 2025-11-24T09:08:47 - app.main: πŸ“¦ Database:
8
- INFO: Started server process [7]
9
  INFO: Waiting for application startup.
10
- INFO: 2025-11-24T09:08:47 - app.main: βœ“ Connected | 44 tables | 5 users
11
- INFO: 2025-11-24T09:08:47 - app.main: πŸ’Ύ Cache & Sessions:
12
- INFO: 2025-11-24T09:08:48 - app.services.otp_service: βœ… OTP Service initialized with Redis storage
13
- INFO: 2025-11-24T09:08:49 - app.main: βœ“ Redis: Connected
14
- INFO: 2025-11-24T09:08:49 - app.main: πŸ”Œ External Services:
15
- INFO: 2025-11-24T09:08:49 - app.main: βœ“ Cloudinary: Connected
16
- INFO: 2025-11-24T09:08:49 - app.main: βœ“ Resend: Configured
17
- INFO: 2025-11-24T09:08:49 - app.main: βœ“ WASender: Connected
18
- INFO: 2025-11-24T09:08:49 - app.main: βœ“ Supabase: Connected | 6 buckets
19
- INFO: 2025-11-24T09:08:49 - app.main: ============================================================
20
- INFO: 2025-11-24T09:08:49 - app.main: βœ… Startup complete | Ready to serve requests
21
- INFO: 2025-11-24T09:08:49 - app.main: ============================================================
22
  INFO: Application startup complete.
23
  INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
24
- INFO: 10.16.33.56:14076 - "GET /health HTTP/1.1" 200 OK
25
- INFO: 10.16.10.8:30521 - "GET /health HTTP/1.1" 200 OK
26
- INFO: 10.16.18.114:19106 - "GET /health HTTP/1.1" 200 OK
27
- INFO: 10.16.33.56:6530 - "GET /health HTTP/1.1" 200 OK
28
- INFO: 2025-11-24T09:10:09 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
29
- INFO: 2025-11-24T09:10:09 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
30
- INFO: 10.16.10.8:54113 - "POST /api/v1/projects/0ade6bd1-e492-4e25-b681-59f42058d29a/team/invite HTTP/1.1" 403 Forbidden
31
- INFO: 10.16.33.56:23611 - "GET /health HTTP/1.1" 200 OK
32
- INFO: 10.16.33.56:10183 - "GET /health HTTP/1.1" 200 OK
 
 
 
 
 
 
 
 
 
1
+ ===== Application Startup at 2025-11-24 09:14:38 =====
2
 
3
+ INFO: Started server process [6]
 
 
 
 
 
4
  INFO: Waiting for application startup.
5
+ INFO: 2025-11-24T09:15:17 - app.main: ============================================================
6
+ INFO: 2025-11-24T09:15:17 - app.main: πŸš€ SwiftOps API v1.0.0 | PRODUCTION
7
+ INFO: 2025-11-24T09:15:17 - app.main: πŸ“Š Dashboard: Enabled
8
+ INFO: 2025-11-24T09:15:17 - app.main: ============================================================
9
+ INFO: 2025-11-24T09:15:17 - app.main: πŸ“¦ Database:
10
+ INFO: 2025-11-24T09:15:17 - app.main: βœ“ Connected | 44 tables | 5 users
11
+ INFO: 2025-11-24T09:15:17 - app.main: πŸ’Ύ Cache & Sessions:
12
+ INFO: 2025-11-24T09:15:18 - app.services.otp_service: βœ… OTP Service initialized with Redis storage
13
+ INFO: 2025-11-24T09:15:19 - app.main: βœ“ Redis: Connected
14
+ INFO: 2025-11-24T09:15:19 - app.main: πŸ”Œ External Services:
 
 
15
  INFO: Application startup complete.
16
  INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
17
+ INFO: 2025-11-24T09:15:19 - app.main: βœ“ Cloudinary: Connected
18
+ INFO: 2025-11-24T09:15:19 - app.main: βœ“ Resend: Configured
19
+ INFO: 2025-11-24T09:15:19 - app.main: βœ“ WASender: Connected
20
+ INFO: 2025-11-24T09:15:19 - app.main: βœ“ Supabase: Connected | 6 buckets
21
+ INFO: 2025-11-24T09:15:19 - app.main: ============================================================
22
+ INFO: 2025-11-24T09:15:19 - app.main: βœ… Startup complete | Ready to serve requests
23
+ INFO: 2025-11-24T09:15:19 - app.main: ============================================================
24
+ INFO: 10.16.10.8:12047 - "GET /?logs=container HTTP/1.1" 200 OK
25
+ INFO: 10.16.33.56:30864 - "GET /health HTTP/1.1" 200 OK
26
+ INFO: 2025-11-24T09:15:33 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
27
+ INFO: 2025-11-24T09:15:33 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
28
+ INFO: 10.16.44.194:48595 - "POST /api/v1/projects/0ade6bd1-e492-4e25-b681-59f42058d29a/team/invite HTTP/1.1" 400 Bad Request
29
+ INFO: 10.16.10.8:47496 - "GET /health HTTP/1.1" 200 OK
30
+ INFO: 10.16.44.194:15297 - "GET /health HTTP/1.1" 200 OK
31
+ INFO: 10.16.10.8:44575 - "GET /health HTTP/1.1" 200 OK
32
+ INFO: 10.16.44.194:23513 - "GET /health HTTP/1.1" 200 OK
33
+
src/app/services/invitation_service.py CHANGED
@@ -490,13 +490,6 @@ class InvitationService:
490
  detail=f"Project {project_id} not found"
491
  )
492
 
493
- # Check project status - only draft and planning can accept invitations
494
- if project.status not in ['draft', 'planning']:
495
- raise HTTPException(
496
- status_code=status.HTTP_400_BAD_REQUEST,
497
- detail=f"Project must be in 'draft' or 'planning' status to invite users. Current status: {project.status}"
498
- )
499
-
500
  # Validate inviter has permission for this project
501
  self._validate_project_invitation_permission(inviter, project)
502
 
@@ -599,13 +592,6 @@ class InvitationService:
599
  logger.warning(f"Project {invitation.project_id} not found when adding user to team")
600
  return
601
 
602
- if project.status not in ['draft', 'planning']:
603
- logger.warning(
604
- f"Project {invitation.project_id} status changed to {project.status}. "
605
- f"User {user_id} not added to team."
606
- )
607
- return
608
-
609
  # Create project team entry
610
  team_member = ProjectTeam(
611
  project_id=invitation.project_id,
 
490
  detail=f"Project {project_id} not found"
491
  )
492
 
 
 
 
 
 
 
 
493
  # Validate inviter has permission for this project
494
  self._validate_project_invitation_permission(inviter, project)
495
 
 
592
  logger.warning(f"Project {invitation.project_id} not found when adding user to team")
593
  return
594
 
 
 
 
 
 
 
 
595
  # Create project team entry
596
  team_member = ProjectTeam(
597
  project_id=invitation.project_id,