From 774211df2b3dabb763ac214dd93ae4cad70b5d40 Mon Sep 17 00:00:00 2001 From: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com> Date: Tue, 7 Oct 2025 12:39:25 +0530 Subject: [PATCH] feat(lighthouse): auto-create tenant config on PATCH --- api/src/backend/api/v1/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/backend/api/v1/views.py b/api/src/backend/api/v1/views.py index 12121cb331..70d8d61d23 100644 --- a/api/src/backend/api/v1/views.py +++ b/api/src/backend/api/v1/views.py @@ -4415,8 +4415,12 @@ class LighthouseTenantConfigViewSet(BaseRLSViewSet): return Response(serializer.data) def partial_update(self, request, *args, **kwargs): - """PATCH endpoint for singleton - no pk required.""" - instance = self.get_object() + """PATCH endpoint for singleton - no pk required. Auto-creates if not exists.""" + # Auto-create tenant config if it doesn't exist (upsert semantics) + instance, created = LighthouseTenantConfiguration.objects.get_or_create( + tenant_id=self.request.tenant_id, + defaults={}, + ) # Extract attributes from JSON:API payload try: