Skip to content

fix: fixed twenty worspace provisiong - #12

Merged
UsamaSadiq merged 2 commits into
foss-mainfrom
jawad/twenty-worspace-provisioning
May 20, 2026
Merged

fix: fixed twenty worspace provisiong#12
UsamaSadiq merged 2 commits into
foss-mainfrom
jawad/twenty-worspace-provisioning

Conversation

@jawad-khan

@jawad-khan jawad-khan commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add SMB_DEFAULT_WORKSPACE_NAME config and shared helpers to resolve the SMB workspace subdomain (with fallback to SMB_NAME).
  • Update dev seeding and SSO provisioning/bootstrap to use the shared helper instead of reading SMB_NAME directly.
  • Add unit tests for the new subdomain utilities.

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:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature
  • CHANGELOG files are updated for the behavior change or additional feature (minor bug fixes and documentation changes should not be included)
  • This PR contains API changes and API documentation is updated accordingly (for critical or behavior change, please inform related parties about them).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_NAME config variable and helper utilities to resolve SMB workspace subdomain (with fallback to SMB_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 on SMB_DEFAULT_WORKSPACE_NAME as 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 = '';

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

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
UsamaSadiq merged commit 248da5c into foss-main May 20, 2026
84 of 88 checks passed
@github-actions

Copy link
Copy Markdown
Fails
🚫

node failed.

Log

Details
�[31mError: �[39m SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:4319:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:6967:27)�[39m
�[90m    at readAllBytes (node:internal/deps/undici/undici:5890:13)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)�[39m
danger-results://tmp/danger-results-3fc17817.json

Generated by 🚫 dangerJS against 98680b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants