-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: org switch issue on consumer when dev org exists #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: org switch issue on consumer when dev org exists #577
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | a88525f | Nov 11 2025, 07:20 PM |
How to use the Graphite Merge QueueAdd the label Main to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Code Review - PR #577: Fix org switch issue on consumer when dev org existsSummaryThis PR re-enables the previously commented-out logic for handling consumer organization switching. The change ensures that when a user's active organization is a non-consumer org (e.g., a dev org), the system automatically switches them to their consumer organization if one exists. Code Quality & Best PracticesPositive Aspects✅ Clear Intent: The logic is straightforward - it prioritizes consumer organizations for users who have one Issues to Address1. Debug Console Statements (Critical) console.log("Consumer organization:", org)
console.log("ALl orgs:", orgs) // Note: typo "ALl"
2. Indentation Issue (Line 46) setOrg(org) // Mixed spaces/tabs
3. Missing } else {
const consumerOrg = orgs?.find((o) => o.metadata?.isConsumer === true)
if (consumerOrg) {
setActiveOrg(consumerOrg.slug)
}
// Missing: what if no consumerOrg is found?
}
Potential BugsBug #1: Race Condition with useEffect(() => {
// ...
}, [session?.session.activeOrganizationId, orgs])
if (!orgs || orgs.length === 0) {
setOrg(org) // Fallback to active org
return
}Bug #2: Infinite Loop Potential
Performance Considerations1. Unnecessary Effect Triggers
2. Async State Update Pattern setActiveOrg(consumerOrg.slug) // This is async but not awaited
Security Concerns1. Organization Data Exposure
2. No Permission Check
Test Coverage
Recommendations SummaryMust Fix Before Merge:
Should Fix: Nice to Have: Suggested Code FixuseEffect(() => {
if (session?.session.activeOrganizationId) {
authClient.organization
.getFullOrganization()
.then((org) => {
if (org.metadata?.isConsumer === true) {
// Already on consumer org - all good
setOrg(org)
} else {
// On a non-consumer org (e.g., dev org)
// Try to switch to consumer org if available
if (!orgs || orgs.length === 0) {
// Org list not loaded yet, use current org
setOrg(org)
return
}
const consumerOrg = orgs.find((o) => o.metadata?.isConsumer === true)
if (consumerOrg) {
// Switch to consumer org
setActiveOrg(consumerOrg.slug)
} else {
// No consumer org exists, stick with current
setOrg(org)
}
}
})
.catch((error) => {
// Silently handle organization fetch failures to prevent unhandled rejections
console.error("Failed to fetch organization:", error)
})
}
}, [session?.session.activeOrganizationId, orgs])Overall Assessment: The logic change itself is sound and addresses a real UX issue. However, the code needs cleanup (remove debug logs, fix formatting) and additional safeguards (handle missing orgs, add fallback setOrg call) before merging. Would you like me to push these fixes or would you prefer to make the changes yourself? |
Pull Request Review: Fix org switch issue on consumer when dev org existsSummaryThis PR addresses an organization switching issue by re-enabling previously commented-out logic that handles consumer organizations. The changes also include a dependency upgrade for Code Quality & Best Practices✅ Positives
|
Pull Request Review: Fix org switch issue on consumer when dev org existsSummaryThis PR re-enables organization switching logic that was previously commented out, adds dependency upgrades, and renames a file from Code Quality & Best Practices✅ Positives
|
Merge activity
|
3a9e7c2 to
a88525f
Compare


No description provided.