Skip to content

The open alternative to Salesforce, designed for AI.

Anonymize workspace names and IDs in upgrade:status output by default (#26799)

Paul Rastoind56c9bcdd79e
diff --git a/packages/twenty-docs/developers/self-host/capabilities/upgrade-guide.mdx b/packages/twenty-docs/developers/self-host/capabilities/upgrade-guide.mdx
index 64aa11664b4..d0035f50e5e 100644
--- a/packages/twenty-docs/developers/self-host/capabilities/upgrade-guide.mdx
+++ b/packages/twenty-docs/developers/self-host/capabilities/upgrade-guide.mdx
@@ -70,7 +70,7 @@ Instance
At: 2026-04-16T11:43:58.823Z
Workspace
- Apple (20202020-1c25-4d02-bf25-6aeccf7ea419)
+ App*** (20202020-***)
Inferred version: 1.23.0
Latest command: 1.23.0_UpdateGlobalObjectContextCommandMenuItemsCommand_1780000005000
Status: Up to date
@@ -88,6 +88,7 @@ Summary
| --- | --- |
| `-w, --workspace-id <id>` | Filter to a specific workspace. Can be passed multiple times. |
| `-f, --failed-only` | Hide up-to-date workspaces, only show behind and failed entries. |
+| `--show-full-identifiers` | Display full workspace names and IDs. By default, only the first three characters of each workspace name and the first section of each workspace ID are shown. |
## Troubleshooting
diff --git a/packages/twenty-server/src/engine/core-modules/upgrade/commands/upgrade-status.command.ts b/packages/twenty-server/src/engine/core-modules/upgrade/commands/upgrade-status.command.ts
index 1a27b25896a..1c2ee8994b8 100644
--- a/packages/twenty-server/src/engine/core-modules/upgrade/commands/upgrade-status.command.ts
+++ b/packages/twenty-server/src/engine/core-modules/upgrade/commands/upgrade-status.command.ts
@@ -11,10 +11,12 @@ import {
UpgradeStatusService,
type WorkspaceUpgradeStatus,
} from 'src/engine/core-modules/upgrade/services/upgrade-status.service';
+import { formatWorkspaceUpgradeStatusLabel } from 'src/engine/core-modules/upgrade/utils/format-workspace-upgrade-status-label.util';
type UpgradeStatusOptions = {
workspaceId?: Set<string>;
failedOnly?: boolean;
+ showFullIdentifiers?: boolean;
};
type GroupedWorkspaceUpgradeStatuses = {
@@ -58,6 +60,15 @@ export class UpgradeStatusCommand extends CommandRunner {
return true;
}
+ @Option({
+ flags: '--show-full-identifiers',
+ description:
+ 'Display full workspace names and IDs instead of the anonymized default',
+ })
+ parseShowFullIdentifiers(): boolean {
+ return true;
+ }
+
private readonly logger = new Logger(UpgradeStatusCommand.name);
constructor(
@@ -94,7 +105,10 @@ export class UpgradeStatusCommand extends CommandRunner {
lines.push(
...this.formatWorkspaceUpgradeStatuses(
groupedWorkspaceUpgradeStatuses,
- options.failedOnly,
+ {
+ failedOnly: options.failedOnly ?? false,
+ anonymize: !options.showFullIdentifiers,
+ },
),
);
@@ -127,7 +141,7 @@ export class UpgradeStatusCommand extends CommandRunner {
private formatWorkspaceUpgradeStatuses(
{ upToDate, behind, failed }: GroupedWorkspaceUpgradeStatuses,
- failedOnly?: boolean,
+ { failedOnly, anonymize }: { failedOnly: boolean; anonymize: boolean },
): string[] {
const lines: string[] = [chalk.bold.underline('Workspace')];
@@ -139,12 +153,16 @@ export class UpgradeStatusCommand extends CommandRunner {
if (!failedOnly) {
for (const workspaceStatus of upToDate) {
- lines.push(...this.formatWorkspaceUpgradeStatus(workspaceStatus));
+ lines.push(
+ ...this.formatWorkspaceUpgradeStatus(workspaceStatus, { anonymize }),
+ );
}
}
for (const workspaceStatus of behind) {
- lines.push(...this.formatWorkspaceUpgradeStatus(workspaceStatus));
+ lines.push(
+ ...this.formatWorkspaceUpgradeStatus(workspaceStatus, { anonymize }),
+ );
}
if (failed.length > 0) {
@@ -172,7 +190,10 @@ export class UpgradeStatusCommand extends CommandRunner {
for (const workspaceStatus of statuses) {
lines.push(
- ...this.formatWorkspaceUpgradeStatus(workspaceStatus, true),
+ ...this.formatWorkspaceUpgradeStatus(workspaceStatus, {
+ anonymize,
+ nested: true,
+ }),
);
}
}
@@ -183,13 +204,15 @@ export class UpgradeStatusCommand extends CommandRunner {
private formatWorkspaceUpgradeStatus(
status: WorkspaceUpgradeStatus,
- nested = false,
+ { anonymize, nested = false }: { anonymize: boolean; nested?: boolean },
): string[] {
const baseIndent = nested ? ' ' : ' ';
const detailIndent = nested ? ' ' : ' ';
- const label = status.displayName
- ? `${status.displayName} (${status.workspaceId})`
- : status.workspaceId;
+ const label = formatWorkspaceUpgradeStatusLabel({
+ workspaceId: status.workspaceId,
+ displayName: status.displayName,
+ anonymize,
+ });
return [
chalk.bold(`${baseIndent}${label}`),
diff --git a/packages/twenty-server/src/engine/core-modules/upgrade/utils/__tests__/format-workspace-upgrade-status-label.util.spec.ts b/packages/twenty-server/src/engine/core-modules/upgrade/utils/__tests__/format-workspace-upgrade-status-label.util.spec.ts
new file mode 100644
index 00000000000..395e4d43745
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/upgrade/utils/__tests__/format-workspace-upgrade-status-label.util.spec.ts
@@ -0,0 +1,65 @@
+import { formatWorkspaceUpgradeStatusLabel } from 'src/engine/core-modules/upgrade/utils/format-workspace-upgrade-status-label.util';
+
+const WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
+
+describe('formatWorkspaceUpgradeStatusLabel', () => {
+ it('should keep the first three characters of the display name and the first section of the workspace id when anonymized', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: 'Apple',
+ anonymize: true,
+ }),
+ ).toBe('App*** (20202020-***)');
+ });
+
+ it('should only display the anonymized workspace id when there is no display name', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: null,
+ anonymize: true,
+ }),
+ ).toBe('20202020-***');
+ });
+
+ it('should mask display names shorter than the visible length', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: 'Ab',
+ anonymize: true,
+ }),
+ ).toBe('Ab*** (20202020-***)');
+ });
+
+ it('should not split multi code unit characters when anonymized', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: 'πŸš€πŸš€πŸš€πŸš€ Rockets',
+ anonymize: true,
+ }),
+ ).toBe('πŸš€πŸš€πŸš€*** (20202020-***)');
+ });
+
+ it('should display the full display name and workspace id when not anonymized', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: 'Apple',
+ anonymize: false,
+ }),
+ ).toBe(`Apple (${WORKSPACE_ID})`);
+ });
+
+ it('should only display the full workspace id when there is no display name and not anonymized', () => {
+ expect(
+ formatWorkspaceUpgradeStatusLabel({
+ workspaceId: WORKSPACE_ID,
+ displayName: '',
+ anonymize: false,
+ }),
+ ).toBe(WORKSPACE_ID);
+ });
+});
diff --git a/packages/twenty-server/src/engine/core-modules/upgrade/utils/format-workspace-upgrade-status-label.util.ts b/packages/twenty-server/src/engine/core-modules/upgrade/utils/format-workspace-upgrade-status-label.util.ts
new file mode 100644
index 00000000000..8fa52f63bff
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/upgrade/utils/format-workspace-upgrade-status-label.util.ts
@@ -0,0 +1,36 @@
+import { isNonEmptyString } from '@sniptt/guards';
+
+const ANONYMIZED_DISPLAY_NAME_VISIBLE_LENGTH = 3;
+const ANONYMIZED_SUFFIX = '***';
+
+type FormatWorkspaceUpgradeStatusLabelParams = {
+ workspaceId: string;
+ displayName: string | null;
+ anonymize: boolean;
+};
+
+const anonymizeWorkspaceId = (workspaceId: string): string =>
+ `${workspaceId.split('-')[0]}-${ANONYMIZED_SUFFIX}`;
+
+const anonymizeDisplayName = (displayName: string): string =>
+ `${Array.from(displayName).slice(0, ANONYMIZED_DISPLAY_NAME_VISIBLE_LENGTH).join('')}${ANONYMIZED_SUFFIX}`;
+
+export const formatWorkspaceUpgradeStatusLabel = ({
+ workspaceId,
+ displayName,
+ anonymize,
+}: FormatWorkspaceUpgradeStatusLabelParams): string => {
+ const formattedWorkspaceId = anonymize
+ ? anonymizeWorkspaceId(workspaceId)
+ : workspaceId;
+
+ if (!isNonEmptyString(displayName)) {
+ return formattedWorkspaceId;
+ }
+
+ const formattedDisplayName = anonymize
+ ? anonymizeDisplayName(displayName)
+ : displayName;
+
+ return `${formattedDisplayName} (${formattedWorkspaceId})`;
+};