UN-2888 [FIX] Add hook for setting default triad for invited users#1877
UN-2888 [FIX] Add hook for setting default triad for invited users#1877pk-zipstack wants to merge 4 commits intomainfrom
Conversation
Add setup_default_adapters_for_user() hook to AuthenticationService and call it from set_user_organization() when an invited user joins an existing organization. This allows the cloud plugin to set up default triad adapters (LLM, embedding, vector DB, x2text) for invited users, fixing silent failures in API deployment creation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughCalls to set up default adapters for an existing organization were added: the controller now invokes Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| backend/account_v2/authentication_controller.py | Adds else branch in set_user_organization() calling setup_default_adapters_for_user() for invited users joining existing orgs, consistent with the frictionless_onboarding pattern |
| backend/account_v2/authentication_service.py | Adds setup_default_adapters_for_user() base method following the same plugin/MethodNotImplemented pattern as frictionless_onboarding() |
Sequence Diagram
sequenceDiagram
participant Client
participant AC as AuthenticationController
participant AS as AuthenticationService
participant OS as OrganizationService
participant DB as Database
Client->>AC: set_user_organization(request, org_id)
AC->>OS: get_organization_by_org_id(org_id)
OS-->>AC: organization (existing or None)
alt Organization is NEW
AC->>OS: create_organization(...)
AC->>AC: create_tenant_user(org, user)
AC->>AS: frictionless_onboarding(org, user)
AS-->>AC: success or MethodNotImplemented (logged)
AC->>AC: create_initial_platform_key(user, org)
else Organization EXISTS (invited user)
AC->>AC: create_tenant_user(org, user)
AC->>AS: setup_default_adapters_for_user(org, user)
Note over AS,DB: Cloud impl creates UserDefaultAdapter records
AS-->>AC: success or MethodNotImplemented (logged)
end
AC-->>Client: HTTP 200 (user + org info)
Prompt To Fix All With AI
This is a comment left during a code review.
Path: backend/account_v2/authentication_controller.py
Line: 217-222
Comment:
**Unexpected exceptions break the invited-user join flow**
Only `MethodNotImplemented` is caught here. If the cloud implementation raises any other exception (e.g., a database error while creating `UserDefaultAdapter`), it will propagate up and cause `set_user_organization()` to return an error to the invited user — preventing them from joining the organization entirely.
This matches the existing `frictionless_onboarding` pattern, but since this hook is in the invited-user path (where a failure has direct UX impact), a broader guard with logging would improve resilience:
```python
else:
try:
self.auth_service.setup_default_adapters_for_user(
organization=organization, user=user
)
except MethodNotImplemented:
logger.info("setup_default_adapters_for_user not implemented")
except Exception:
logger.exception(
"setup_default_adapters_for_user failed for user "
f"{user.user_id} in org {organization.id}"
)
```
This keeps the join flow intact even when adapter setup fails, and surfaces the error in logs for debugging.
How can I resolve this? If you propose a fix, please make it concise.Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.
Reviews (4): Last reviewed commit: "Merge branch 'main' into fix/set-default..." | Re-trigger Greptile
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/account_v2/authentication_controller.py (1)
216-222: Consider adding a log message for consistency withfrictionless_onboarding.The
frictionless_onboardingexception handler at line 208 logs"frictionless_onboarding not implemented", but this handler silently passes. Adding a similar log message would improve debugging consistency for OSS deployments.♻️ Suggested change
else: try: self.auth_service.setup_default_adapters_for_user( organization=organization, user=user ) except MethodNotImplemented: - pass + logger.info("setup_default_adapters_for_user not implemented")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/account_v2/authentication_controller.py` around lines 216 - 222, The except block swallowing MethodNotImplemented for self.auth_service.setup_default_adapters_for_user should log a message like the frictionless_onboarding handler does; update the except MethodNotImplemented block in authentication_controller (around setup_default_adapters_for_user) to call the same logger used for frictionless_onboarding and emit a clear message such as "setup_default_adapters_for_user not implemented" and include minimal context (organization id/name and user id/email) to aid debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@backend/account_v2/authentication_controller.py`:
- Around line 216-222: The except block swallowing MethodNotImplemented for
self.auth_service.setup_default_adapters_for_user should log a message like the
frictionless_onboarding handler does; update the except MethodNotImplemented
block in authentication_controller (around setup_default_adapters_for_user) to
call the same logger used for frictionless_onboarding and emit a clear message
such as "setup_default_adapters_for_user not implemented" and include minimal
context (organization id/name and user id/email) to aid debugging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 708b08ff-27b6-4bb5-b5a2-12840cd88c63
📒 Files selected for processing (2)
backend/account_v2/authentication_controller.pybackend/account_v2/authentication_service.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Praveen Kumar <praveen@zipstack.com>
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
|



What
setup_default_adapters_for_user()hook method toAuthenticationService(raisesMethodNotImplemented)set_user_organization()inAuthenticationControllerfor non-new organizations (invited user flow)Why
UserDefaultAdapterrecord is missingHow
setup_default_adapters_for_user()to the baseAuthenticationServicefollowing the same plugin pattern asfrictionless_onboarding()(raisesMethodNotImplementedin base, implemented in cloud)set_user_organization(), aftercreate_tenant_user(), the hook is called in theelsebranch (non-new org) with a try/except forMethodNotImplementedUserDefaultAdapterfor the invited userCan this PR break any existing features? If yes, please list possible items. If no, please explain why.
MethodNotImplementedin the base implementation, which is caught and silently ignored. This is the same pattern used byfrictionless_onboarding(). OSS deployments are unaffected.Database Migrations
Env Config
Related Issues or PRs
fix/set-default-triad-for-invited-userDependencies Versions
Notes on Testing
pluggable_apps/platform_admin/tests/test_set_default_adapters.pycovering:Checklist
🤖 Generated with Claude Code