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 5 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
WalkthroughController now calls 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_service.py | Adds setup_default_adapters_for_user() stub that raises MethodNotImplemented, identical in structure to the existing frictionless_onboarding() method — clean and consistent. |
| backend/account_v2/authentication_controller.py | Calls the new hook in the else branch of set_user_organization() (existing org / invited-user path) with MethodNotImplemented caught and logged at INFO level including user.email — consistent with the established pattern. |
Sequence Diagram
sequenceDiagram
participant U as Invited User
participant AC as AuthenticationController
participant AS as AuthenticationService
participant OS as OrganizationService
U->>AC: set_user_organization(org_id)
AC->>OS: get_organization_by_org_id(org_id)
OS-->>AC: organization (already exists)
Note over AC: new_organization = False
AC->>AC: create_tenant_user(org, user)
alt new_organization = True
AC->>AS: frictionless_onboarding(org, user)
Note over AS: Creates full default setup for org creator (cloud only)
AC->>AC: create_initial_platform_key()
else new_organization = False (invited user)
AC->>AS: setup_default_adapters_for_user(org, user)
alt MethodNotImplemented (OSS)
AS-->>AC: raise MethodNotImplemented
AC->>AC: logger.info("not implemented")
else Cloud implementation
AS-->>AC: UserDefaultAdapter records created (idempotent)
end
end
AC-->>U: HTTP 200 (user + org info)
Reviews (5): Last reviewed commit: "[FIX] Improve log message for setup_defa..." | 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>
| organization=organization, user=user | ||
| ) | ||
| except MethodNotImplemented: | ||
| logger.info("setup_default_adapters_for_user not implemented") |
There was a problem hiding this comment.
NIT: Make the log more useful by stating what happens as a result. You can mention that default adapters are not set for the user
Address review comment: log user email and explain that default adapters will not be set when the method is not implemented. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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