fix: enable organization creation from project selector#392
Conversation
📝 WalkthroughWalkthroughNavigation to create a new organization now passes a ChangesOrganization Creation State via Query Parameter
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
|
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/start/src/routes/_steps.onboarding.project.tsx`:
- Around line 33-35: The current preprocess for createNewOrg coerces any
non-true input to false, hiding invalid values; change the preprocess to return
true only when value === true or value === 'true', and otherwise return the
original value so z.boolean() will reject malformed inputs (e.g. use preprocess:
(v) => (v === true || v === 'true' ? true : v) with the existing z.boolean() and
.optional()). This keeps the symbol createNewOrg and its surrounding schema but
ensures invalid query values fail validation instead of becoming false.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ea8cfbb8-8cdf-4fc0-9107-f692b6130d04
📒 Files selected for processing (2)
apps/start/src/components/project-selector.tsxapps/start/src/routes/_steps.onboarding.project.tsx
| createNewOrg: z | ||
| .preprocess((value) => value === true || value === 'true', z.boolean()) | ||
| .optional(), |
There was a problem hiding this comment.
Harden createNewOrg parsing to reject malformed values instead of coercing them to false.
Line 34 currently maps any non-true input to false (e.g. 'tru', 'yes'), which silently masks invalid query values.
Suggested fix
const validateSearch = z.object({
inviteId: z.string().optional(),
- createNewOrg: z
- .preprocess((value) => value === true || value === 'true', z.boolean())
- .optional(),
+ createNewOrg: z
+ .preprocess((value) => {
+ if (value === undefined) return undefined;
+ if (value === true || value === 'true') return true;
+ if (value === false || value === 'false') return false;
+ return value;
+ }, z.boolean())
+ .optional(),
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| createNewOrg: z | |
| .preprocess((value) => value === true || value === 'true', z.boolean()) | |
| .optional(), | |
| createNewOrg: z | |
| .preprocess((value) => { | |
| if (value === undefined) return undefined; | |
| if (value === true || value === 'true') return true; | |
| if (value === false || value === 'false') return false; | |
| return value; | |
| }, z.boolean()) | |
| .optional(), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/start/src/routes/_steps.onboarding.project.tsx` around lines 33 - 35,
The current preprocess for createNewOrg coerces any non-true input to false,
hiding invalid values; change the preprocess to return true only when value ===
true or value === 'true', and otherwise return the original value so z.boolean()
will reject malformed inputs (e.g. use preprocess: (v) => (v === true || v ===
'true' ? true : v) with the existing z.boolean() and .optional()). This keeps
the symbol createNewOrg and its surrounding schema but ensures invalid query
values fail validation instead of becoming false.
Summary
Fixed a dashboard issue preventing self-hosted users from creating additional organizations.
Multi-organization support is already available in self-hosted deployments and does not require any extra environment flags beyond the standard self-hosted configuration (
SELF_HOSTED=true,DASHBOARD_URL,API_URL). The backend onboarding flow already supports creating new organizations and automatically assigns the creator theorg:adminrole.The issue was in the UI flow. The "New organization" option in the organization selector redirected users to the onboarding page, which defaulted to "Use existing workspace" when an organization already existed. This change updates the flow to open the workspace creation mode directly.
Changes
Updated organization selector navigation
project-selector.tsxUpdated onboarding page initialization
_steps.onboarding.project.tsxNotes
The
POST https://api.openpanel.dev/track401error is unrelated to organization creation. It comes from the dashboard telemetry client attempting to send analytics to hosted OpenPanel whenVITE_OP_CLIENT_IDis present or misconfigured.Fixes #388
Summary by CodeRabbit