fix: fixed twenty worspace provisiong - #12
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new SMB workspace subdomain configuration (SMB_DEFAULT_WORKSPACE_NAME) and centralizes “which subdomain should SSO land/join into?” logic into a shared utility, updating seeding and SSO provisioning flows to use it consistently.
Changes:
- Add
SMB_DEFAULT_WORKSPACE_NAMEconfig variable and helper utilities to resolve SMB workspace subdomain (with fallback toSMB_NAME) and detect SMB bundle deployments. - Update dev seeding behavior and SSO user provisioning/bootstrap command to use the new helper instead of directly reading
SMB_NAME. - Add Jest unit tests for the new subdomain helper utilities and update existing specs to cover the new configuration behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/twenty-server/src/engine/workspace-manager/dev-seeder/services/dev-seeder.service.ts | Switch SMB-mode detection from SMB_NAME checks to isSmbBundleDeployment(...) for permissions/data seeding branches. |
| packages/twenty-server/src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant.ts | Seed “apple” workspace subdomain now prefers SMB_DEFAULT_WORKSPACE_NAME, then SMB_NAME, then 'apple'. |
| packages/twenty-server/src/engine/core-modules/twenty-config/utils/get-smb-workspace-subdomain.util.ts | New utility to resolve SMB workspace subdomain from config/env and detect SMB deployments. |
| packages/twenty-server/src/engine/core-modules/twenty-config/utils/tests/get-smb-workspace-subdomain.util.spec.ts | Unit tests for the new SMB workspace subdomain utilities. |
| packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts | Add SMB_DEFAULT_WORKSPACE_NAME and adjust SMB_NAME metadata description. |
| packages/twenty-server/src/engine/core-modules/auth/services/sso-user-provisioning.service.ts | Use getSmbWorkspaceSubdomain(...) for landing workspace selection and update error messaging. |
| packages/twenty-server/src/engine/core-modules/auth/services/sso-user-provisioning.service.spec.ts | Update tests to reflect new config key precedence and revised error message. |
| packages/twenty-server/src/database/commands/bootstrap-sso-admin.command.ts | Use getSmbWorkspaceSubdomain(...) and update command description/errors accordingly. |
| packages/twenty-server/src/database/commands/bootstrap-sso-admin.command.spec.ts | Update tests to reflect new config key precedence and revised error message. |
Comments suppressed due to low confidence (1)
packages/twenty-server/src/engine/workspace-manager/dev-seeder/services/dev-seeder.service.ts:203
- Same as above: this comment says the data fixture is skipped “when SMB_NAME is set”, but the actual guard is
!isSmbBundleDeployment(...)(which depends onSMB_DEFAULT_WORKSPACE_NAMEas well). Updating the wording will keep the docs accurate now that SMB_NAME and the workspace subdomain can diverge.
// member rows reference core."user" via userId FK, which we didn't seed
// when SMB_NAME is set, so skip the entire data fixture in that mode and
// leave the workspace clean. SSO users provisioned via ForwardAuth get
// their workspaceMember rows created at sign-in time.
if (!isSmbBundleDeployment(this.twentyConfigService)) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
147
to
+153
| // initPermissions assigns admin/limited/guest/member roles to the demo | ||
| // userWorkspace rows (Tim, Jane, Jony, Phil + ~200 random). When SMB_NAME | ||
| // is set those userWorkspace rows weren't seeded above, so fall back to | ||
| // the minimal init path (member role + workspace activation, no | ||
| // user-specific assignments). The first SSO user provisioned via | ||
| // ForwardAuth picks up the member role from defaultRoleId on sign-in. | ||
| if (this.twentyConfigService.get('SMB_NAME')) { | ||
| if (isSmbBundleDeployment(this.twentyConfigService)) { |
Comment on lines
+41
to
+44
| const SEED_WORKSPACE_SUBDOMAIN = | ||
| process.env.SMB_DEFAULT_WORKSPACE_NAME?.trim() || | ||
| process.env.SMB_NAME?.trim() || | ||
| 'apple'; |
Comment on lines
1715
to
+1731
| @ConfigVariablesMetadata({ | ||
| group: ConfigVariablesGroup.ADVANCED_SETTINGS, | ||
| description: | ||
| 'Per-deployment tenant identifier wired into every foss-server-bundle-devstack app. Twenty uses it both as the seed workspace subdomain (see seeder-workspaces.constant.ts) and as the workspace SSO users join on first login. Required when AUTH_TYPE=SSO.', | ||
| 'Per-deployment tenant identifier (portal hostname segment) for the foss-server-bundle-devstack. Used by the frontend runtime config when AUTH_TYPE=SSO.', | ||
| type: ConfigVariableType.STRING, | ||
| }) | ||
| @IsOptional() | ||
| SMB_NAME = ''; | ||
|
|
||
| @ConfigVariablesMetadata({ | ||
| group: ConfigVariablesGroup.ADVANCED_SETTINGS, | ||
| description: | ||
| 'SMB workspace subdomain for seeding and SSO auto-join (same as Plane/Outline/SurfSense). Falls back to SMB_NAME when unset.', | ||
| type: ConfigVariableType.STRING, | ||
| }) | ||
| @IsOptional() | ||
| SMB_DEFAULT_WORKSPACE_NAME = ''; |
Comment on lines
339
to
+343
| // downstream FK reference (seedAgents / seedMetadataEntities) would | ||
| // break against missing userWorkspace rows. Same single switch as the | ||
| // workspace subdomain/displayName override in seeder-workspaces.constant.ts. | ||
| const seedDemoUsersAndDependents = | ||
| !this.twentyConfigService.get('SMB_NAME'); | ||
| const seedDemoUsersAndDependents = !isSmbBundleDeployment( | ||
| this.twentyConfigService, |
Comment on lines
+42
to
44
| const SEED_WORKSPACE_SUBDOMAIN = | ||
| getSmbWorkspaceSubdomainFromProcessEnv() || 'apple'; | ||
| const SEED_WORKSPACE_DISPLAY_NAME = |
Comment on lines
1715
to
1722
| @ConfigVariablesMetadata({ | ||
| group: ConfigVariablesGroup.ADVANCED_SETTINGS, | ||
| description: | ||
| 'Per-deployment tenant identifier wired into every foss-server-bundle-devstack app. Twenty uses it both as the seed workspace subdomain (see seeder-workspaces.constant.ts) and as the workspace SSO users join on first login. Required when AUTH_TYPE=SSO.', | ||
| 'Per-deployment tenant identifier (portal hostname segment) for the foss-server-bundle-devstack. Used by the frontend runtime config when AUTH_TYPE=SSO.', | ||
| type: ConfigVariableType.STRING, | ||
| }) | ||
| @IsOptional() | ||
| SMB_NAME = ''; |
|
|
||
| expect(getSmbWorkspaceSubdomainFromProcessEnv()).toBe('acme-team'); | ||
| }); | ||
|
|
UsamaSadiq
approved these changes
May 20, 2026
LogDetails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SMB_DEFAULT_WORKSPACE_NAMEconfig and shared helpers to resolve the SMB workspace subdomain (with fallback toSMB_NAME).SMB_NAMEdirectly.Additional information
TIP: Provide additional information such as screenshots, benchmarks, reference to other repositories or alternative solutions
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]