fix: Setup wizard forced back into registration on upgrade when Show_Setup_Wizard is env-overridden - #41254
Conversation
🦋 Changeset detectedLatest commit: f4452a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (2)
WalkthroughThis PR fixes the setup wizard being forced back to registration on first start after upgrade when ChangesSetup wizard env-override fix
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ensureCloudWorkspaceRegistered
participant SettingsModel
ensureCloudWorkspaceRegistered->>SettingsModel: findOneById(Show_Setup_Wizard, projection)
SettingsModel-->>ensureCloudWorkspaceRegistered: value, valueSource, processEnvValue
ensureCloudWorkspaceRegistered->>ensureCloudWorkspaceRegistered: check value !== completed
ensureCloudWorkspaceRegistered->>ensureCloudWorkspaceRegistered: check env-pinned value matches processEnvValue
ensureCloudWorkspaceRegistered->>SettingsModel: updateValueById(Show_Setup_Wizard, in_progress)
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
|
Looks like this PR is ready to merge! 🎉 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41254 +/- ##
===========================================
+ Coverage 69.06% 69.07% +0.01%
===========================================
Files 3655 3655
Lines 143366 143372 +6
Branches 25725 25697 -28
===========================================
+ Hits 99018 99040 +22
+ Misses 40041 40033 -8
+ Partials 4307 4299 -8
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
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/meteor/server/startup/cloudRegistration.ts`:
- Around line 20-21: Remove the implementation comments in cloudRegistration.ts
so the guard logic remains comment-free and compliant with the coding guideline.
Keep the existing conditional behavior around the env override check in the
startup flow, but delete the explanatory lines above the guard since the
variable names and condition already make the intent clear.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95db733e-7f7b-41a2-9e80-215deddbe865
📒 Files selected for processing (7)
.changeset/setup-wizard-env-override-upgrade.mdapps/meteor/app/settings/server/SettingsRegistry.tsapps/meteor/app/settings/server/functions/overrideGenerator.tsapps/meteor/server/startup/cloudRegistration.tsapps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.tsapps/meteor/tests/unit/app/settings/server/functions/settings.tests.tsapps/meteor/tests/unit/server/startup/cloudRegistration.tests.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (1/4)
- GitHub Check: 🔨 Test API (EE) / MongoDB 8.0 coverage (1/1)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/settings/server/functions/overrideGenerator.tsapps/meteor/tests/unit/server/startup/cloudRegistration.tests.tsapps/meteor/tests/unit/app/settings/server/functions/settings.tests.tsapps/meteor/server/startup/cloudRegistration.tsapps/meteor/app/settings/server/SettingsRegistry.tsapps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/setup-wizard-env-override-upgrade.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/app/settings/server/functions/overrideGenerator.tsapps/meteor/tests/unit/server/startup/cloudRegistration.tests.tsapps/meteor/tests/unit/app/settings/server/functions/settings.tests.tsapps/meteor/server/startup/cloudRegistration.tsapps/meteor/app/settings/server/SettingsRegistry.tsapps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/app/settings/server/functions/overrideGenerator.tsapps/meteor/tests/unit/server/startup/cloudRegistration.tests.tsapps/meteor/tests/unit/app/settings/server/functions/settings.tests.tsapps/meteor/server/startup/cloudRegistration.tsapps/meteor/app/settings/server/SettingsRegistry.tsapps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/app/settings/server/functions/overrideGenerator.tsapps/meteor/tests/unit/server/startup/cloudRegistration.tests.tsapps/meteor/tests/unit/app/settings/server/functions/settings.tests.tsapps/meteor/server/startup/cloudRegistration.tsapps/meteor/app/settings/server/SettingsRegistry.tsapps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.ts
🔇 Additional comments (7)
.changeset/setup-wizard-env-override-upgrade.md (1)
1-5: LGTM!apps/meteor/app/settings/server/SettingsRegistry.ts (1)
86-90: LGTM!Also applies to: 183-183
apps/meteor/app/settings/server/functions/overrideGenerator.ts (1)
43-43: LGTM!apps/meteor/tests/unit/app/settings/server/functions/overrideGenerator.tests.ts (1)
22-32: LGTM!Also applies to: 34-43
apps/meteor/tests/unit/app/settings/server/functions/settings.tests.ts (1)
144-186: LGTM!apps/meteor/server/startup/cloudRegistration.ts (1)
6-18: LGTM!apps/meteor/tests/unit/server/startup/cloudRegistration.tests.ts (1)
1-75: LGTM!
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 7 files
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="apps/meteor/app/settings/server/functions/overrideGenerator.ts">
<violation number="1" location="apps/meteor/app/settings/server/functions/overrideGenerator.ts:43">
P2: Env-pinned settings can still remain unmarked as env-sourced when `processEnvValue` already matches but `valueSource` is stale or missing. Since the guard returns before writing `valueSource: 'processEnvValue'`, consider only skipping when the source stamp is already correct too.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Proposed changes (including videos or screenshots)
On the first boot after a version upgrade,
ensureCloudWorkspaceRegistered()flipsShow_Setup_Wizardfromcompletedtoin_progresswheneverCloud_Workspace_Client_Id/Cloud_Workspace_Client_Secretare both empty. Air-gapped workspaces running offline licenses always meet this condition, so admins get redirected into a registration wizard they cannot complete online — even whenOVERWRITE_SETTING_Show_Setup_Wizard=completedis explicitly set.The env override is applied during settings init, before the version-change callback runs, so the flip wins for the life of that process (it self-heals on the next restart, when the override is re-applied and the version-change callback no longer fires).
The fix
ensureCloudWorkspaceRegistered()now skips the flip when the current value ofShow_Setup_Wizardwas authored by the env override:valueSource === 'processEnvValue' && value === processEnvValue. Thevalue === processEnvValuepart means a value changed after the override (by an admin or another process) invalidates the pin naturally, with no reset logic.For that check to be reliable, two supporting changes in the settings machinery were needed — previously the
processEnvValuesource stamp was only persisted when the override changed the stored value, so a setting whose stored value already matched the env var never got stamped:overrideGeneratornow returns a stamped setting even when the env value equals the stored value (if not already stamped).SettingsRegistry.addnow persists the setting when only the source stamp changed (valueequal,valueSource/processEnvValuediffer). This converges: subsequent boots with the same env produce no writes.A side effect of the stamping fix is that settings whose env override equals their stored value are now correctly marked as env-sourced (previously they kept
valueSource: 'packageValue'), which also makesresetValueByIdand any othervalueSourceconsumer see the accurate source.Issue(s)
CORE-2377
Air-gapped/offline-license workspaces are pushed into the cloud registration step of the setup wizard after every upgrade, despite an explicit config directive to skip it.
Steps to test or reproduce
Cloud_Workspace_Client_Id/Cloud_Workspace_Client_Secretempty) andOVERWRITE_SETTING_Show_Setup_Wizard=completed.db.migrations.updateOne({ _id: 'upgrade' }, { $set: { hash: 'fake' } }), then restart.Show_Setup_Wizardflips toin_progressand admins are redirected into the wizard. With the fix, it stayscompleted(and its document now carriesvalueSource: 'processEnvValue').Unit tests cover the stamping behavior (
overrideGenerator,SettingsRegistrypersistence + cross-boot convergence) and the guard plus the pre-existing behaviors ofensureCloudWorkspaceRegistered(registered workspace, wizard not completed, diverged value, and the intended flip when unregistered with no pin).Further comments
The bug was verified in a live manual test on both sides: with the guard the setting document receives no write at all on an upgrade boot; without it, it flips within ~300ms of the migration hash update.
Because the pin is persisted state (not a runtime env read), it also protects upgrade boots where the env var is no longer present — the operator's provisioning survives until the value is changed by someone else.
Summary by CodeRabbit