fix(organizations): remove org calls when billing is disabled#1211
fix(organizations): remove org calls when billing is disabled#1211waleedlatif1 merged 1 commit intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR addresses a bug where OSS (open source software) users were encountering 404 errors when organization-related API calls were made on deployments with billing disabled. The changes modify the organization store (apps/sim/stores/organization/store.ts) to add early returns that prevent organization API calls when the NEXT_PUBLIC_BILLING_ENABLED environment variable is false.
The implementation adds billing checks in three key methods:
loadData(): Returns early with empty organizations array and null active organization when billing is disabledrefreshOrganization(): Exits early to prevent organization refresh callscreateOrganization(): Returns early with an error message indicating organizations aren't available
This change fits into the codebase's architecture by maintaining the existing organization store structure while providing graceful degradation for OSS deployments. The organization functionality is inherently tied to billing and subscription systems, so when billing is disabled, the store appropriately falls back to a single-user mode without team/organization features. This allows the platform to function properly for individual users in OSS environments while preventing the 404 errors that were occurring during platform initialization.
Confidence score: 3/5
- This PR addresses a real issue but has partial coverage that may leave some edge cases unhandled
- Score reflects incomplete protection - some organization methods remain unguarded which could still cause issues if called programmatically
- Pay close attention to
apps/sim/stores/organization/store.tsto ensure all organization-related methods are consistently protected
1 file reviewed, 1 comment
| if (!isBillingEnabled) { | ||
| logger.debug('Billing disabled, skipping organization data loading') | ||
| set({ | ||
| organizations: [], | ||
| activeOrganization: null, | ||
| hasTeamPlan: false, | ||
| hasEnterprisePlan: false, | ||
| isLoading: false, | ||
| error: null, | ||
| lastFetched: Date.now(), | ||
| }) | ||
| return | ||
| } |
There was a problem hiding this comment.
logic: Early return sets empty state when billing disabled, but other methods like setActiveOrganization and seat management aren't protected
Summary
remove org calls when billing is disabled to prevent the users that have billing disabled (OSS) from getting 404's. removed it from the places that programatically get called when the user loads into the platform,
Type of Change
Testing
Tested manually.
Checklist