From 20848cb7820cd319586df54a79f1716fd641be95 Mon Sep 17 00:00:00 2001 From: Chandrasekharan M Date: Mon, 11 May 2026 18:18:22 +0530 Subject: [PATCH 1/3] [FIX] Wrap set_user_organization in transaction.atomic The new-org branch creates the org row, then calls frictionless onboarding and the initial platform key. Failures mid-flow leave an orphan org with no adapters or key, and subsequent logins skip onboarding entirely (gated on new_organization). Atomic ensures the org rolls back on any failure so retries get a clean fresh-org path. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/account_v2/authentication_controller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/account_v2/authentication_controller.py b/backend/account_v2/authentication_controller.py index 19eac7baa9..fcfe11b68c 100644 --- a/backend/account_v2/authentication_controller.py +++ b/backend/account_v2/authentication_controller.py @@ -3,6 +3,7 @@ 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 @@ -163,6 +164,7 @@ def user_organizations(self, request: Request) -> Any: return response + @transaction.atomic def set_user_organization(self, request: Request, organization_id: str) -> Response: user: User = request.user new_organization = False From 13517d4e9a8607c1f30b41458c5b626cf7f19e6d Mon Sep 17 00:00:00 2001 From: Chandrasekharan M Date: Mon, 11 May 2026 18:26:20 +0530 Subject: [PATCH 2/3] =?UTF-8?q?[MISC]=20Worktree=20skill=20=E2=80=94=20use?= =?UTF-8?q?=20--no-track=20to=20prevent=20accidental=20main=20pushes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without --no-track, a later `git push -u origin ` can be reported by the server as also fast-forwarding main, landing commits on main. --- .claude/skills/worktree/SKILL.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.claude/skills/worktree/SKILL.md b/.claude/skills/worktree/SKILL.md index 50f8fb5e51..a1339a29b3 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** From 178d1c4ade68f57ff0fd42c8b8562a55b3ac0ffe Mon Sep 17 00:00:00 2001 From: Chandrasekharan M Date: Wed, 13 May 2026 15:26:01 +0530 Subject: [PATCH 3/3] [FIX] Use logger.exception in authorization_callback Preserves the traceback when the OAuth callback hits the safety-net catch. Behaviour unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/account_v2/authentication_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/account_v2/authentication_controller.py b/backend/account_v2/authentication_controller.py index fcfe11b68c..7c89158006 100644 --- a/backend/account_v2/authentication_controller.py +++ b/backend/account_v2/authentication_controller.py @@ -101,8 +101,8 @@ def authorization_callback( 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: