Skip to content

feat: add @rocket.chat/env package for centralized env var validation#40024

Draft
ggazzo wants to merge 2 commits intodevelopfrom
feat/env-validation-package
Draft

feat: add @rocket.chat/env package for centralized env var validation#40024
ggazzo wants to merge 2 commits intodevelopfrom
feat/env-validation-package

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Apr 1, 2026

Summary

  • Adds new @rocket.chat/env package that centralizes environment variable validation using AJV schemas
  • Provides a typed, frozen env singleton with fail-fast behavior if required vars (e.g. MONGO_URL) are missing
  • Handles boolean coercion ('true'/'yes'true), string-to-number coercion, and default values
  • Covers all 59 env vars used in apps/meteor/ (excluding dynamically mutated ones like MAIL_URL)

Usage after migration (future PRs):

// Before:
const port = parseInt(String(process.env.PORT)) || 3000;
const testMode = process.env.TEST_MODE === 'true';

// After:
import { env } from '@rocket.chat/env';
env.PORT       // number, defaults to 3000
env.TEST_MODE  // boolean | undefined

Test plan

  • 18 unit tests passing with 100% statement coverage
  • Build succeeds (yarn build in packages/env/)
  • Validate startup fails without MONGO_URL
  • Validate defaults are applied correctly
  • Validate boolean/number coercion works

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added schema-driven environment configuration: validates required MongoDB URL, applies sensible defaults, coerces types (strings→numbers/booleans), strips unknown vars, and returns an immutable parsed config with clear validation errors.
  • Tests
    • Added thorough tests covering validation failures, defaults, type coercion, boolean variants, unknown-field stripping, and immutability.

Create a new package that validates all environment variables at startup
using AJV schemas, providing type-safe access with proper coercion and
fail-fast behavior when required vars are missing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Apr 1, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

⚠️ No Changeset found

Latest commit: b3ef1c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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 9 files

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Walkthrough

Adds a new private package @rocket.chat/env that defines environment types and a JSON schema, provides a parseEnv function using Ajv with coercion/defaults/cleanup, exposes a frozen env instance at module load, and includes tests plus build/test/lint config and scripts.

Changes

Cohort / File(s) Summary
Package manifest & tooling
packages/env/package.json, packages/env/tsconfig.json, packages/env/jest.config.ts
New package manifest with build/test/lint scripts and dependencies; TypeScript config extending monorepo tsconfig and emitting declarations; Jest config using @rocket.chat/jest-presets/server.
Public surface / barrel
packages/env/src/index.ts, packages/env/src/env.ts
Adds barrel exports and an exported, frozen env constant initialized by parseEnv() at module evaluation.
Types & schema
packages/env/src/types.ts, packages/env/src/schema.ts
Introduces IRocketChatEnv TypeScript interface and corresponding JSON schema covering required MONGO_URL, numerous optional strings/numbers/booleans, defaults, and nullable system passthroughs.
Parser implementation
packages/env/src/parse.ts
Adds parseEnv(raw?) which normalizes boolean-like strings, strips undefineds, runs Ajv validation with coercion/defaults/remove-additional, throws aggregated validation errors, and returns a frozen IRocketChatEnv.
Tests
packages/env/src/parse.spec.ts
New Jest tests verifying validation failure for missing MONGO_URL, default application, numeric and boolean coercion, unknown key removal, and immutability of returned config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type: feature

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: introducing a new @rocket.chat/env package for centralized environment variable validation, which matches the core objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.50%. Comparing base (4364222) to head (b3ef1c8).
⚠️ Report is 8 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40024      +/-   ##
===========================================
- Coverage    70.55%   70.50%   -0.05%     
===========================================
  Files         3263     3270       +7     
  Lines       116664   116778     +114     
  Branches     21040    21077      +37     
===========================================
+ Hits         82311    82338      +27     
- Misses       32300    32384      +84     
- Partials      2053     2056       +3     
Flag Coverage Δ
e2e 60.45% <ø> (-0.08%) ⬇️
e2e-api 48.04% <ø> (-0.08%) ⬇️
unit 70.95% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai bot added the type: feature Pull requests that introduces new feature label Apr 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/env/src/schema.ts (1)

6-77: Consider removing section comments in implementation code.

The grouping comments are clear, but this file currently relies heavily on inline comments. Prefer self-descriptive structure/naming to match repo guidance.

As per coding guidelines: "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/env/src/schema.ts` around lines 6 - 77, Remove the inline section
comments and make the grouping explicit via descriptive variables/objects and a
single combined export; e.g. extract the blocks containing keys like MONGO_URL,
ADMIN_NAME, EVENT_LOOP_LAG_MS, ADMIN_EMAIL, ADMIN_EMAIL_VERIFIED,
HTTP_DEFAULT_TIMEOUT, HOME, NODE_ENV into named consts such as requiredEnv,
defaultStringEnv, defaultNumberEnv, optionalStringEnv, optionalBooleanEnv,
optionalNumberEnv, and systemPassthroughEnv, then spread/merge those into the
final exported schema (so locate the object containing keys like MONGO_URL,
ADMIN_NAME, EVENT_LOOP_LAG_MS, ADMIN_EMAIL, ADMIN_EMAIL_VERIFIED,
HTTP_DEFAULT_TIMEOUT, HOME and refactor into named groups), removing the comment
lines in favor of the self-descriptive variable names.
packages/env/src/types.ts (1)

2-69: Apply the same comment-minimization approach in this interface file.

The section headers are readable, but they conflict with the repository preference to avoid implementation comments.

As per coding guidelines: "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/env/src/types.ts` around lines 2 - 69, Remove the inline section
header comments in packages/env/src/types.ts (e.g., "// Required", "// Optional
with defaults — strings", "// Optional booleans", etc.) and leave only the type
declarations (symbols like MONGO_URL, ADMIN_NAME, ADMIN_EMAIL,
ADMIN_EMAIL_VERIFIED, HTTP_DEFAULT_TIMEOUT, HOME, etc.) intact; simply delete
those comment lines so the file conforms to the "avoid code comments in the
implementation" guideline without changing any interface names or types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/env/src/index.ts`:
- Line 4: The barrel currently re-exports the env singleton which triggers
parseEnv() at module load; remove the named export "export { env } from
'./env';" from the barrel index so importing utilities (like parseEnv or
envSchema) won't eagerly validate environment variables, and ensure you still
re-export parseEnv and envSchema from './env' (or keep their existing
re-exports) so consumers that need only those utilities can import them without
forcing creation of the env singleton; consumers that need the validated
singleton should import env explicitly from './env'.

---

Nitpick comments:
In `@packages/env/src/schema.ts`:
- Around line 6-77: Remove the inline section comments and make the grouping
explicit via descriptive variables/objects and a single combined export; e.g.
extract the blocks containing keys like MONGO_URL, ADMIN_NAME,
EVENT_LOOP_LAG_MS, ADMIN_EMAIL, ADMIN_EMAIL_VERIFIED, HTTP_DEFAULT_TIMEOUT,
HOME, NODE_ENV into named consts such as requiredEnv, defaultStringEnv,
defaultNumberEnv, optionalStringEnv, optionalBooleanEnv, optionalNumberEnv, and
systemPassthroughEnv, then spread/merge those into the final exported schema (so
locate the object containing keys like MONGO_URL, ADMIN_NAME, EVENT_LOOP_LAG_MS,
ADMIN_EMAIL, ADMIN_EMAIL_VERIFIED, HTTP_DEFAULT_TIMEOUT, HOME and refactor into
named groups), removing the comment lines in favor of the self-descriptive
variable names.

In `@packages/env/src/types.ts`:
- Around line 2-69: Remove the inline section header comments in
packages/env/src/types.ts (e.g., "// Required", "// Optional with defaults —
strings", "// Optional booleans", etc.) and leave only the type declarations
(symbols like MONGO_URL, ADMIN_NAME, ADMIN_EMAIL, ADMIN_EMAIL_VERIFIED,
HTTP_DEFAULT_TIMEOUT, HOME, etc.) intact; simply delete those comment lines so
the file conforms to the "avoid code comments in the implementation" guideline
without changing any interface names or types.
🪄 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: 825f0fc0-f9a6-4258-a389-a3296bdfcca5

📥 Commits

Reviewing files that changed from the base of the PR and between 8a30bfb and 9bfea64.

📒 Files selected for processing (9)
  • packages/env/jest.config.ts
  • packages/env/package.json
  • packages/env/src/env.ts
  • packages/env/src/index.ts
  • packages/env/src/parse.spec.ts
  • packages/env/src/parse.ts
  • packages/env/src/schema.ts
  • packages/env/src/types.ts
  • packages/env/tsconfig.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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:

  • packages/env/src/env.ts
  • packages/env/jest.config.ts
  • packages/env/src/index.ts
  • packages/env/src/schema.ts
  • packages/env/src/parse.ts
  • packages/env/src/parse.spec.ts
  • packages/env/src/types.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • packages/env/src/parse.spec.ts
🧠 Learnings (26)
📓 Common learnings
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • packages/env/tsconfig.json
  • packages/env/jest.config.ts
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.

Applied to files:

  • packages/env/tsconfig.json
  • packages/env/src/index.ts
  • packages/env/package.json
  • packages/env/src/types.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

Applied to files:

  • packages/env/tsconfig.json
📚 Learning: 2026-03-06T18:09:17.867Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.

Applied to files:

  • packages/env/tsconfig.json
  • packages/env/jest.config.ts
  • packages/env/package.json
  • packages/env/src/parse.spec.ts
  • packages/env/src/types.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use `.spec.ts` extension for test files (e.g., `login.spec.ts`)

Applied to files:

  • packages/env/tsconfig.json
📚 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:

  • packages/env/src/env.ts
  • packages/env/jest.config.ts
  • packages/env/src/index.ts
  • packages/env/src/schema.ts
  • packages/env/src/parse.ts
  • packages/env/src/parse.spec.ts
  • packages/env/src/types.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:

  • packages/env/src/env.ts
  • packages/env/jest.config.ts
  • packages/env/src/index.ts
  • packages/env/src/schema.ts
  • packages/env/src/parse.ts
  • packages/env/src/parse.spec.ts
  • packages/env/src/types.ts
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.

Applied to files:

  • packages/env/src/index.ts
  • packages/env/src/schema.ts
  • packages/env/src/types.ts
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • packages/env/src/schema.ts
  • packages/env/src/types.ts
📚 Learning: 2026-03-16T23:33:15.721Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: apps/meteor/app/api/server/v1/users.ts:862-869
Timestamp: 2026-03-16T23:33:15.721Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs (e.g., PR `#39676` for users.register in apps/meteor/app/api/server/v1/users.ts), calls to `this.parseJsonQuery()` inside migrated handlers are intentionally preserved without adding a corresponding `query` AJV schema to the route options. Adding query-param schemas for the `fields`/`sort`/`query` parameters consumed by `parseJsonQuery()` is a separate cross-cutting concern shared by many endpoints (e.g., users.create, users.update, users.list) and is explicitly out of scope for individual endpoint migration PRs. Do not flag the absence of a `query` schema for `parseJsonQuery()` usage as a violation of OpenAPI/AJV contract during migration reviews.

Applied to files:

  • packages/env/src/parse.ts
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.

Applied to files:

  • packages/env/src/parse.ts
  • packages/env/package.json
  • packages/env/src/types.ts
📚 Learning: 2026-03-17T16:08:37.572Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 39690
File: packages/ui-voip/package.json:11-11
Timestamp: 2026-03-17T16:08:37.572Z
Learning: In `packages/ui-voip/package.json` (RocketChat/Rocket.Chat), the team deliberately chose to use `rm -rf dist` directly in the `"build"` script instead of `rimraf`, as they decided against introducing the `rimraf` dependency for this package. Do not flag `rm -rf dist` in the ui-voip build script as a cross-platform issue requiring rimraf.

Applied to files:

  • packages/env/package.json
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure clean state for each test execution in Playwright tests

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/env/src/parse.spec.ts
📚 Learning: 2026-03-16T21:50:42.118Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.

Applied to files:

  • packages/env/src/types.ts
🔇 Additional comments (7)
packages/env/tsconfig.json (1)

1-10: Looks good for package compilation boundaries.

rootDir, outDir, declaration emit, and spec exclusion are aligned with a library package setup.

packages/env/src/parse.ts (1)

50-68: Validation pipeline is solid and fail-fast behavior is correctly implemented.

Normalization, coercion/defaulting, error aggregation, and frozen return are well wired.

packages/env/src/parse.spec.ts (1)

5-120: Comprehensive spec coverage for parser behavior.

This suite exercises the key contracts (required vars, defaults, coercion, stripping unknown keys, immutability) with clear test names.

packages/env/jest.config.ts (1)

1-6: Jest preset wiring looks correct.

Using the shared server preset here is consistent with monorepo conventions.

packages/env/src/env.ts (1)

1-4: Singleton initialization is consistent with fail-fast startup validation.

packages/env/package.json (2)

2-30: Clean package scaffold for the new env module.

Manifest layout, scripts, and runtime/dev dependency split look coherent for introducing @rocket.chat/env.


24-25: No action needed. ts-jest@29.4.6 explicitly supports jest@^30.0.0, and jest@30.2.0 is within that range. The version pairing is compatible.

			> Likely an incorrect or invalid review comment.

export type { RocketChatEnv } from './types';
export { envSchema } from './schema';
export { parseEnv } from './parse';
export { env } from './env';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify eager import chain from barrel -> env singleton -> parseEnv() call
sed -n '1,40p' packages/env/src/index.ts
sed -n '1,40p' packages/env/src/env.ts
sed -n '50,80p' packages/env/src/parse.ts

Repository: RocketChat/Rocket.Chat

Length of output: 954


🏁 Script executed:

#!/bin/bash
# Check if MONGO_URL is required in the schema
rg -i "mongo_url" packages/env/src/ -A 3 -B 3

# Check for any imports of env from the barrel
rg "from ['\"].*packages/env['\"]" --type ts --type tsx | grep -i "env['\"]" | head -20

# Also check for imports from `@rocket.chat/env` since it might be published
rg "from ['\"]@rocket.chat/env['\"]" --type ts --type tsx | grep "env['\"]" | head -20

Repository: RocketChat/Rocket.Chat

Length of output: 2233


🏁 Script executed:

#!/bin/bash
# Search for imports of env from packages/env barrel (no type filtering)
rg "from ['\"].*packages/env['\"]" | head -30

# Also search for imports from `@rocket.chat/env` if it's published as a package
rg "from ['\"]@rocket.chat/env['\"]" | head -30

# Check if env is specifically imported and used in the codebase
rg "import.*env.*from.*packages/env" | head -20

Repository: RocketChat/Rocket.Chat

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Broader search for imports of env package
rg "import.*from.*['\"].*env['\"]" --max-count 50 | grep -E "(packages/env|@rocket.chat/env)"

# Check package.json files for `@rocket.chat/env` dependency
find . -name "package.json" -type f | xargs grep -l "@rocket.chat/env\|packages/env" 2>/dev/null

# Check if env is used in apps that might depend on packages/env
rg "import.*env.*from" apps/ --max-count 30 | head -20

Repository: RocketChat/Rocket.Chat

Length of output: 93


🏁 Script executed:

#!/bin/bash
# Check the package.json of the env package
cat packages/env/package.json

# Check if this package is referenced in the root package.json
grep -A 10 -B 10 "packages/env" package.json 2>/dev/null || echo "Not found in root package.json"

# Check if there's a workspace definition that includes packages/env
grep -i "@rocket.chat/env\|packages/env" pnpm-workspace.yaml workspaces.json 2>/dev/null || echo "Not found in workspace config"

Repository: RocketChat/Rocket.Chat

Length of output: 789


Remove the env export to prevent eager environment validation when importing utilities.

The barrel export at line 4 (export { env } from './env') causes env.ts to execute immediately on any import of the barrel. Since env.ts calls parseEnv() at module load and MONGO_URL is a required environment variable, consumers importing only parseEnv or envSchema for utilities will fail if MONGO_URL is not set, even though they don't need the env singleton. Remove this export to defer validation until env is explicitly imported.

Suggested change
 export type { RocketChatEnv } from './types';
 export { envSchema } from './schema';
 export { parseEnv } from './parse';
-export { env } from './env';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export { env } from './env';
export type { RocketChatEnv } from './types';
export { envSchema } from './schema';
export { parseEnv } from './parse';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/env/src/index.ts` at line 4, The barrel currently re-exports the env
singleton which triggers parseEnv() at module load; remove the named export
"export { env } from './env';" from the barrel index so importing utilities
(like parseEnv or envSchema) won't eagerly validate environment variables, and
ensure you still re-export parseEnv and envSchema from './env' (or keep their
existing re-exports) so consumers that need only those utilities can import them
without forcing creation of the env singleton; consumers that need the validated
singleton should import env explicitly from './env'.

The eslint naming-convention rule requires interfaces to start with `I`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ggazzo ggazzo added this to the 8.4.0 milestone Apr 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/env/src/types.ts`:
- Line 2: Remove the inline section comment markers (e.g., the "// Required"
comment and similar section comments present at the other reported locations)
from this module so the file follows the repo TS guideline forbidding
implementation comments; locate occurrences of those exact comment strings
(e.g., "// Required" and other short section comments at the referenced spots)
and delete them, leaving only code and necessary JSDoc/type comments if any.
🪄 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: 6ba20a93-311b-4664-9afc-0dc66857beab

📥 Commits

Reviewing files that changed from the base of the PR and between 9bfea64 and b3ef1c8.

📒 Files selected for processing (4)
  • packages/env/src/env.ts
  • packages/env/src/index.ts
  • packages/env/src/parse.ts
  • packages/env/src/types.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/env/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/env/src/env.ts
  • packages/env/src/parse.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 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:

  • packages/env/src/types.ts
🧠 Learnings (9)
📓 Common learnings
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: In Rocket.Chat PRs, keep feature PRs free of unrelated lockfile-only dependency bumps; prefer reverting lockfile drift or isolating such bumps into a separate "chore" commit/PR, and always use yarn install --immutable with the Yarn version pinned in package.json via Corepack.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2026-03-16T21:50:42.118Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2026-03-06T18:09:17.867Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.

Applied to files:

  • packages/env/src/types.ts
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • packages/env/src/types.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 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:

  • packages/env/src/types.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:

  • packages/env/src/types.ts
🔇 Additional comments (1)
packages/env/src/types.ts (1)

1-74: Strong env contract shape overall.

The required/default-backed and optional fields are clearly typed and align well with the centralized validation/coercion approach.

@@ -0,0 +1,74 @@
export interface IRocketChatEnv {
// Required
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove section comments to match repo TS guideline.

These inline section comments should be removed from implementation code in this repo.

Suggested cleanup
 export interface IRocketChatEnv {
-	// Required
 	MONGO_URL: string;
 
-	// Optional with defaults — strings
 	ADMIN_NAME: string;
 	ADMIN_USERNAME: string;
 	BIND_IP: string;
 	DEPLOY_METHOD: string;
 	DEPLOY_PLATFORM: string;
 	INSTANCE_IP: string;
 
-	// Optional with defaults — numbers
 	EVENT_LOOP_LAG_MS: number;
 	HEAP_USAGE_PERCENT: number;
 	HTTP_FORWARDED_COUNT: number;
 	MAX_RESUME_LOGIN_TOKENS: number;
 	PORT: number;
 
-	// Optional strings
 	ADMIN_EMAIL?: string;
 	ADMIN_PASS?: string;
 	BUGSNAG_CLIENT?: string;
@@
-	// Optional booleans
 	ADMIN_EMAIL_VERIFIED?: boolean;
@@
-	// Optional numbers
 	HTTP_DEFAULT_TIMEOUT?: number;
 	PROMETHEUS_PORT?: number;
 	RATE_LIMITER_SLOWDOWN_RATE?: number;
 
-	// System pass-through
 	HOME?: string;
 	HOMEPATH?: string;
 	NODE_ENV?: string;
 	TMPDIR?: string;
 	USERPROFILE?: string;
 }

As per coding guidelines: **/*.{ts,tsx,js} → “Avoid code comments in the implementation”.

Also applies to: 5-5, 13-13, 20-20, 43-43, 63-63, 68-68

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/env/src/types.ts` at line 2, Remove the inline section comment
markers (e.g., the "// Required" comment and similar section comments present at
the other reported locations) from this module so the file follows the repo TS
guideline forbidding implementation comments; locate occurrences of those exact
comment strings (e.g., "// Required" and other short section comments at the
referenced spots) and delete them, leaving only code and necessary JSDoc/type
comments if any.

@ggazzo ggazzo marked this pull request as draft April 1, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant