Skip to content

chore: remove dead feature flags#20460

Open
charlesBochet wants to merge 5 commits into
mainfrom
chore/remove-dead-feature-flags
Open

chore: remove dead feature flags#20460
charlesBochet wants to merge 5 commits into
mainfrom
chore/remove-dead-feature-flags

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

@charlesBochet charlesBochet commented May 11, 2026

Summary

Two related cleanups, following the same pattern as #19916 and #19074.

Dead feature flags

Drops four feature flags whose only references are the enum entry and the generated GraphQL/SDK files:

  • IS_COMMAND_MENU_ITEM_ENABLED — never read anywhere.
  • IS_DATASOURCE_MIGRATED — already commented @deprecated. Zero non-generated consumers.
  • IS_RICH_TEXT_V1_MIGRATED — the 1-19 migration that gated it was removed in chore: remove completed migration feature flags and upgrade commands <= 1.18 #19074; the flag became dead at that point.
  • IS_CONNECTED_ACCOUNT_MIGRATED — only read by the 1-21 migrate-messaging-infrastructure-to-metadata command as an early-return guard, but the flag was never written anywhere in the codebase, so the guard never fired (and that workspace command is now removed entirely — see below).

Generated GraphQL/SDK schemas and the workspace-entity-manager test mock are trimmed to match.

1-21 workspace commands

Same pattern as #19074 (which removed workspace commands ≤ 1.18). Twenty is now on 2-5; the 1-21 workspace commands have long since run on every active workspace and are dead code.

Removes:

  • All 14 workspace commands under upgrade-version-command/1-21/ (compose-email menu item, key-value-pair index, datasource backfill, message-thread backfill, dedup engine commands, select-all fixes, AI response format migration, edit-layout label, drop messaging FKs, folder parent-id migration, messaging-infra-to-metadata, navigation refactor, message-thread label fix, search-menu-item label).
  • The 1-21-upgrade-version-command.module.ts registration and the V1_21_UpgradeVersionCommandModule import from WorkspaceCommandProviderModule.

Kept (intentionally): the 3 1-21-instance-command-fast-* files. Unlike workspace commands (which mutate data), instance commands carry schema deltas still required by current entity definitions (AddViewFieldGroupIdIndex, MigrateMessagingCalendarToCore, AddEmailThreadWidgetType). They remain registered in INSTANCE_COMMANDS and '1.21.0' stays in TWENTY_PREVIOUS_VERSIONS. They will fold away naturally on a future version bump when a CoreMigrationCheck-style snapshot picks them up.

Test plan

  • npx nx typecheck twenty-shared
  • npx nx typecheck twenty-server
  • npx nx typecheck twenty-front
  • npx prettier --check on the changed files
  • npx oxlint on the changed server files
  • npx jest feature-flag (4 suites, 20 tests pass)
  • npx jest workspace-entity-manager (1 suite, 5 tests pass)

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 removes four dead feature flags from the shared FeatureFlagKey enum and updates the corresponding generated GraphQL/SDK artifacts and a server test mock to match, reducing unused surface area in the feature-flag system and upgrade commands.

Changes:

  • Remove IS_COMMAND_MENU_ITEM_ENABLED, IS_DATASOURCE_MIGRATED, IS_RICH_TEXT_V1_MIGRATED, and IS_CONNECTED_ACCOUNT_MIGRATED from FeatureFlagKey.
  • Drop the unused FeatureFlagService / IS_CONNECTED_ACCOUNT_MIGRATED early-return guard from the 1.21 messaging infrastructure migration command.
  • Update generated GraphQL/SDK schemas and a workspace entity manager test mock to reflect the trimmed enum.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/twenty-shared/src/types/FeatureFlagKey.ts Removes the four dead feature-flag keys from the shared enum source of truth.
packages/twenty-server/src/engine/twenty-orm/entity-manager/workspace-entity-manager.spec.ts Updates mocked featureFlagsMap to no longer include the removed keys.
packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500012000-migrate-messaging-infrastructure-to-metadata.command.ts Removes the unused feature-flag guard and dependency from the upgrade command.
packages/twenty-front/src/generated-metadata/graphql.ts Regenerates client metadata GraphQL types to remove the deleted enum values.
packages/twenty-front/src/generated-admin/graphql.ts Regenerates admin GraphQL types to remove the deleted enum values.
packages/twenty-client-sdk/src/metadata/generated/schema.ts Updates SDK generated TypeScript schema types/constants for the trimmed enum.
packages/twenty-client-sdk/src/metadata/generated/schema.graphql Updates SDK generated GraphQL schema to remove the deleted enum values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@charlesBochet charlesBochet changed the title chore: remove dead feature flags chore: remove dead feature flags and 1-21 upgrade commands May 11, 2026
@twenty-ci-bot-public
Copy link
Copy Markdown

twenty-ci-bot-public Bot commented May 11, 2026

🔍 Automated Pre-Review

No issues detected - This PR is ready for human review.


View details

Automated pre-review. Human approval still required.

@twenty-ci-bot-public
Copy link
Copy Markdown

twenty-ci-bot-public Bot commented May 11, 2026

🚀 Preview Environment Ready!

Your preview environment is available at: https://purse-fcc-sellers-involve.trycloudflare.com

This environment will automatically shut down after 5 hours.

@twenty-ci-bot-public
Copy link
Copy Markdown

twenty-ci-bot-public Bot commented May 11, 2026

📊 API Changes Report

GraphQL Schema Changes

GraphQL Schema Changes

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
⚠️ Breaking changes or errors detected in GraphQL schema

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
    at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
    at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
    at async Promise.all (index 0)
    at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
    at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
    at async Promise.all (index 4)
    at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
    at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error generating diff

GraphQL Metadata Schema Changes

GraphQL Metadata Schema Changes

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
⚠️ Breaking changes or errors detected in GraphQL metadata schema

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
    at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
    at /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
    at async Promise.all (index 0)
    at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
    at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
    at async Promise.all (index 4)
    at async loadFile (/opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
    at async /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error generating diff

REST API Analysis Error

⚠️ Error occurred while analyzing REST API changes

Error Output

REST Metadata API Analysis Error

⚠️ Error occurred while analyzing REST Metadata API changes

Error Output

⚠️ Please review these API changes carefully before merging.

@charlesBochet charlesBochet force-pushed the chore/remove-dead-feature-flags branch from 7fe5a28 to 5a50869 Compare May 11, 2026 20:00
@charlesBochet charlesBochet changed the title chore: remove dead feature flags and 1-21 upgrade commands chore: remove dead feature flags May 11, 2026
@charlesBochet charlesBochet changed the title chore: remove dead feature flags chore: remove dead feature flags and 1-21 upgrade commands May 11, 2026
@charlesBochet charlesBochet force-pushed the chore/remove-dead-feature-flags branch from 690e51f to 7207415 Compare May 11, 2026 20:27
@charlesBochet charlesBochet changed the title chore: remove dead feature flags and 1-21 upgrade commands chore: remove dead feature flags and 1-21 workspace commands May 11, 2026
Comment on lines 10 to 15

@Module({
imports: [
V1_21_UpgradeVersionCommandModule,
V1_22_UpgradeVersionCommandModule,
V1_23_UpgradeVersionCommandModule,
V2_0_UpgradeVersionCommandModule,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The PR incompletely removes support for upgrading from version 1.21.0. The version remains in TWENTY_PREVIOUS_VERSIONS while its associated workspace commands are deleted, causing silent upgrade failures.
Severity: CRITICAL

Suggested Fix

To fix this, remove '1.21.0' from the TWENTY_PREVIOUS_VERSIONS array. This will ensure the upgrade sequence generator correctly identifies 1.21.0 as an unsupported version and throws the intended error, preventing data corruption.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts#L10-L15

Potential issue: The pull request aims to drop support for upgrading from version
`1.21.0` but fails to remove `'1.21.0'` from the `TWENTY_PREVIOUS_VERSIONS` list. While
the workspace commands for the 1.21 upgrade path are deleted, the version's continued
presence in the supported versions list prevents the system from correctly erroring out
for users on `1.21.0`. Instead, the upgrade process will silently skip the missing 1.21
workspace commands and proceed to execute the 1.22 commands on un-migrated data, leading
to database corruption.

Did we get this right? 👍 / 👎 to inform future reviews.

Drops four feature flags that have no remaining runtime consumers:

- IS_COMMAND_MENU_ITEM_ENABLED — never read anywhere
- IS_DATASOURCE_MIGRATED — already commented @deprecated, no consumers
- IS_RICH_TEXT_V1_MIGRATED — never read; the 1-19 migration that used
  it was removed in #19074
- IS_CONNECTED_ACCOUNT_MIGRATED — only read in the 1-21 messaging
  migration command as an idempotency guard, but the flag is never
  written, so the guard never fired. Drop the guard since the
  underlying save() upserts are already idempotent.

Updates the FeatureFlagKey enum, the workspace-entity-manager test
mock, and the generated GraphQL/SDK schemas accordingly.
Same cleanup pattern as #19074 which removed upgrade commands <= 1.18.
Twenty is now on 2-5; the 1-21 commands have long since run on every
active workspace and are dead code.

Deletes all 18 1-21 instance and workspace commands plus the
V1_21_UpgradeVersionCommandModule registration, and drops the three
1-21 instance command entries from INSTANCE_COMMANDS.
@charlesBochet charlesBochet force-pushed the chore/remove-dead-feature-flags branch from 7207415 to 7c9fa00 Compare May 11, 2026 20:37
Picks up the schema drift accumulated on main that touched these
generated files (SSO/AvailableWorkspace/BillingEntitlement/etc.) so
the Check for Pending Code Generation CI step passes.
@charlesBochet charlesBochet added the ci:allow-previous-version-upgrade-mutation Bypass `ci-server.yaml` `server-previous-version-upgrade-mutation-guard` job. label May 11, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 16 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500007000-fix-select-all-command-menu-items.command.ts">

<violation number="1">
P2: Use the workspace custom application identifier when calling `validateBuildAndRunWorkspaceMigration` instead of the standard application identifier.

(Based on your team's feedback about using workspaceCustom application context for validate/build/run migrations.) [FEEDBACK_USED]</violation>
</file>

<file name="packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts">

<violation number="1">
P1: Re-adding `V1_21_UpgradeVersionCommandModule` keeps the removed 1-21 workspace commands wired into the upgrade pipeline. This reintroduces deprecated command providers instead of removing them.</violation>
</file>

<file name="packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500014000-fix-message-thread-view-and-label-identifier.command.ts">

<violation number="1">
P2: View-field migration is not idempotent: it always deletes and recreates `allMessageThreads` fields, even when already synced.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Reordered types only - restoring V1_21_UpgradeVersionCommandModule
changes module load order, which the SDK metadata generator reflects.
@charlesBochet charlesBochet changed the title chore: remove dead feature flags and 1-21 workspace commands chore: remove dead feature flags May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

-PR: awaiting review ci:allow-previous-version-upgrade-mutation Bypass `ci-server.yaml` `server-previous-version-upgrade-mutation-guard` job.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants