Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3465 [FIX] Wrap set_user_organization in transaction.atomic (#1954)

Chandrasekharan M8b29fea02e68
diff --git a/.claude/skills/worktree/SKILL.md b/.claude/skills/worktree/SKILL.md
index 50f8fb5e5..a1339a29b 100644
--- a/.claude/skills/worktree/SKILL.md
+++ b/.claude/skills/worktree/SKILL.md
@@ -26,7 +26,10 @@ Create isolated worktrees for parallel development. Ends by providing commands t
```bash
git fetch origin main
mkdir -p "$(dirname "$WORKTREE_PATH")"
- git worktree add -b "{branch}" "$WORKTREE_PATH" origin/main
+ # --no-track: do NOT set the new branch's upstream to origin/main.
+ # Without it, a later `git push -u origin {branch}` can be reported by
+ # the server as also fast-forwarding main, landing commits on main.
+ git worktree add --no-track -b "{branch}" "$WORKTREE_PATH" origin/main
```
4. **Copy config files**
diff --git a/backend/account_v2/authentication_controller.py b/backend/account_v2/authentication_controller.py
index 56982ed9b..d27bb5065 100644
--- a/backend/account_v2/authentication_controller.py
+++ b/backend/account_v2/authentication_controller.py
@@ -3,6 +3,7 @@ from typing import Any
from django.conf import settings
from django.contrib.auth import logout as django_logout
+from django.db import transaction
from django.db.utils import IntegrityError
from django.http import HttpRequest
from django.middleware import csrf
@@ -100,8 +101,8 @@ class AuthenticationController:
return self.auth_service.handle_authorization_callback(
request=request, backend=backend
)
- except Exception as ex:
- logger.error(f"Error while handling authorization callback: {ex}")
+ except Exception:
+ logger.exception("Error while handling authorization callback")
return redirect("/error")
def user_organizations(self, request: Request) -> Any:
@@ -163,6 +164,7 @@ class AuthenticationController:
return response
+ @transaction.atomic
def set_user_organization(self, request: Request, organization_id: str) -> Response:
user: User = request.user
new_organization = False