Skip to content

chore: replace console.* with structured @rocket.chat/logger across production code#39216

Open
smirk-dev wants to merge 1 commit intoRocketChat:developfrom
smirk-dev:chore/replace-console-with-structured-logger
Open

chore: replace console.* with structured @rocket.chat/logger across production code#39216
smirk-dev wants to merge 1 commit intoRocketChat:developfrom
smirk-dev:chore/replace-console-with-structured-logger

Conversation

@smirk-dev
Copy link
Contributor

@smirk-dev smirk-dev commented Mar 1, 2026

Proposed changes

Replace raw console.log/warn/error/info/debug calls with the project's structured @rocket.chat/logger (pino-based) across 120 production files.

What this PR does

Category Files Approach
Server-side (apps/meteor/server, apps/meteor/app/*/server, ee/apps/*) 54 Replace with new Logger('ModuleName') from @rocket.chat/logger
Client-side / packages without logger dep 65 Add // eslint-disable-next-line no-console comments
Skipped (intentional console usage) 2 showBox.ts, settings.mocks.ts — left as-is

ESLint rule enabled

Uncommented the existing no-console: 'warn' rule in packages/eslint-config to prevent regressions.

Why this matters

  • Observability: Structured pino JSON logs are compatible with log aggregation (Datadog, ELK, Loki) — console.log is not
  • Log levels: Production deployments can suppress debug noise via runtime config without code changes
  • Error context: logger.error({ msg, err }) captures stack traces in structured fields vs flat text from console.error(string)
  • Regression prevention: The no-console: warn lint rule ensures no new console.log creeps in
  • Already proven pattern: 30+ modules already used @rocket.chat/logger — this closes the gap for the remaining ~270 occurrences

Hotspots addressed

  • apps/meteor/server/startup/initialData.ts (20 replacements)
  • apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts (12 replacements)
  • apps/meteor/app/utils/server/functions/getMongoInfo.ts (12 replacements)
  • ee/apps/ddp-streamer/src/service.ts (11 replacements)
  • apps/meteor/server/oauth2-server/model.ts (9 replacements)

Summary by CodeRabbit

  • New Features

    • Added validation and deprecation warnings across various API endpoints and services for better error reporting.
    • Enhanced file upload system with new customization hooks for validation and error handling.
  • Bug Fixes

    • Improved error handling and logging in authentication, file uploads, and data export processes.
  • Chores

    • Implemented centralized logging system across modules for enhanced observability and debugging.

…roduction code

- Server-side (54 files): Replace console.log/warn/error/info/debug with
  Logger instances from @rocket.chat/logger for structured JSON logging
- Client-side (65 files): Add eslint-disable-next-line no-console comments
  for packages without @rocket.chat/logger dependency
- Enable no-console: 'warn' ESLint rule to prevent regressions
- Skip intentional console usage (showBox.ts, settings.mocks.ts)

Benefits:
- Structured pino-based logging compatible with log aggregation (ELK, Loki)
- Runtime log-level filtering without code changes
- Error context captured in structured fields vs flat text
- Lint rule prevents new console.log from creeping in
@smirk-dev smirk-dev requested review from a team as code owners March 1, 2026 10:38
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 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
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2026

⚠️ No Changeset found

Latest commit: 74e7a95

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

This pull request systematically replaces console logging statements (console.log, console.warn, console.error) with the Logger utility across the codebase. Most files introduce a Logger import, instantiate a module-level logger, and replace console calls with logger methods. Some files add ESLint directives to suppress no-console warnings where console usage is retained.

Changes

Cohort / File(s) Summary
API Logging Migration
apps/meteor/app/api/server/ApiClass.ts, apps/meteor/app/api/server/api.ts, apps/meteor/app/api/server/helpers/getUserInfo.ts, apps/meteor/app/api/server/lib/MultipartUploadHandler.ts, apps/meteor/app/api/server/v1/commands.ts, apps/meteor/app/api/server/v1/e2e.ts, apps/meteor/app/api/server/v1/rooms.ts
Introduces Logger instances and replaces console.error/warn/log with logger equivalents in error handling and validation paths.
Apps Bridge Logging
apps/meteor/app/apps/server/bridges/details.ts, apps/meteor/app/apps/server/bridges/livechat.ts
Adds Logger and replaces console.warn with logger.warn for app setting change notifications and deprecation warnings.
Autotranslate & Cloud Logging
apps/meteor/app/autotranslate/client/lib/autotranslate.ts, apps/meteor/app/cloud/server/index.ts
Adds Logger instance for cloud registration logging and ESLint disable directives for remaining client-side console usage.
Error Handler & File Upload Logging
apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts, apps/meteor/app/file-upload/ufs/Webdav/server.ts, apps/meteor/app/file/server/file.server.ts
Centralizes error logging via Logger in unhandled rejection/exception handlers and file upload operations.
Core Services Logging
apps/meteor/app/lib/server/methods/restartServer.ts, apps/meteor/app/license/client/index.ts, apps/meteor/app/mailer/server/api.ts, apps/meteor/app/settings/server/applyMiddlewares.ts, apps/meteor/app/settings/server/functions/overrideGenerator.ts
Replaces console logging with Logger instances for restart timeouts, license checks, email operations, and settings middleware.
Connector & UI Logging
apps/meteor/app/smarsh-connector/server/functions/generateEml.ts, apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts, apps/meteor/app/ui/client/lib/recorderjs/AudioRecorder.ts, apps/meteor/app/ui/client/lib/recorderjs/videoRecorder.ts
Adds Logger initialization and ESLint directives for audio/video recorder error logging and legacy room manager warnings.
Utilities & Mongo Logging
apps/meteor/app/utils/server/functions/getMongoInfo.ts
Introduces Logger for MongoDB connection error handling with centralized error reporting.
Enterprise License & Startup
apps/meteor/ee/app/license/server/startup.ts, apps/meteor/ee/server/api/licenses.ts, apps/meteor/ee/server/apps/storage/AppGridFSSourceStorage.ts, apps/meteor/ee/server/hooks/federation/index.ts, apps/meteor/ee/server/lib/audit/methods.ts, apps/meteor/ee/server/local-services/instance/service.ts, apps/meteor/ee/server/startup/presence.ts
Adds Logger instances for enterprise features including licensing, federation, audit, and presence service error handling.
Data Processing & Migrations
apps/meteor/server/lib/dataExport/processDataDownloads.ts, apps/meteor/server/lib/roles/addUserRoles.ts, apps/meteor/server/modules/notifications/notifications.module.ts, apps/meteor/server/modules/streamer/streamer.module.ts
Replaces console calls with Logger; includes validation logic for role lists and scope checking in addUserRoles.
OAuth & Authentication
apps/meteor/server/oauth2-server/model.ts, apps/meteor/server/oauth2-server/oauth.ts
Converts debug console.log to logger.info across OAuth2 model methods and authentication flows.
Routes & Services
apps/meteor/server/routes/avatar/utils.ts, apps/meteor/server/services/authorization/canAccessRoom.ts, apps/meteor/server/services/authorization/service.ts, apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts
Adds Logger for avatar access warnings, authorization service initialization, and Markdown parsing error handling.
Startup & File Management
apps/meteor/server/startup/initialData.ts, apps/meteor/server/startup/migrations/v312.ts, apps/meteor/server/startup/migrations/v319.ts, apps/meteor/server/startup/serverRunning.ts, apps/meteor/server/ufs/ufs-local.ts, apps/meteor/server/ufs/ufs-methods.ts, apps/meteor/server/ufs/ufs-server.ts, apps/meteor/server/ufs/ufs-store.ts
Replaces console logging with Logger instances throughout startup initialization, migration scripts, and file storage operations. ufs-store.ts adds new StoreOptions callback interface fields.
Account & Authorization Microservices
ee/apps/account-service/src/service.ts, ee/apps/authorization-service/src/service.ts, ee/apps/ddp-streamer/src/Client.ts, ee/apps/ddp-streamer/src/DDPStreamer.ts, ee/apps/ddp-streamer/src/Streamer.ts, ee/apps/ddp-streamer/src/configureServer.ts, ee/apps/ddp-streamer/src/service.ts
Adds Logger instances for microservice health checks, streaming client/server error handling, and connection management.
Enterprise Services
ee/apps/omnichannel-transcript/src/service.ts, ee/apps/presence-service/src/service.ts, ee/apps/queue-worker/src/service.ts
Introduces Logger for health checks and service initialization in omnichannel, presence, and queue worker services.
Federation Logging
ee/packages/federation-matrix/src/events/ping.ts, ee/packages/federation-matrix/src/helpers/createOrUpdateFederatedUser.ts, ee/packages/federation-matrix/tests/helper/config.ts, ee/packages/federation-matrix/tests/helper/synapse-client.ts
Adds ESLint directives and console logging for federation event handling, user creation, and test helpers; includes retry attempt logging.
License & Network
ee/packages/license/src/showLicense.ts, ee/packages/network-broker/src/index.ts, ee/packages/presence/src/Presence.ts, ee/packages/presence/src/lib/PresenceReaper.ts
Replaces console.log with logger.info for license debugging; adds console output to network broker startup and presence updates.
API Client & Apps Engine Core
packages/api-client/src/index.ts, packages/apps-engine/src/client/AppClientManager.ts, packages/apps-engine/src/client/AppsEngineUIClient.ts
Changes error handling in API client from throw to console.warn; adds console output for enabled apps and ESLint directives for client initialization.
Apps Engine Managers
packages/apps-engine/src/server/AppManager.ts, packages/apps-engine/src/server/ProxiedApp.ts, packages/apps-engine/src/server/accessors/LivechatRead.ts, packages/apps-engine/src/server/compiler/AppPackageParser.ts, packages/apps-engine/src/server/logging/AppConsole.ts, packages/apps-engine/src/server/managers/AppApi.ts, packages/apps-engine/src/server/managers/AppListenerManager.ts, packages/apps-engine/src/server/managers/AppPermissionManager.ts, packages/apps-engine/src/server/managers/AppSchedulerManager.ts, packages/apps-engine/src/server/managers/AppSlashCommand.ts, packages/apps-engine/src/server/managers/AppVideoConfProvider.ts
Adds extensive console logging for app compilation errors, deprecation warnings, UUID validation, listener validation, and error handling; includes ESLint directives.
Apps Engine Runtime & Testing
packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts, packages/apps-engine/tests/runner.ts, packages/cas-validate/src/validate.ts
Adds comprehensive console logging throughout Deno runtime subprocess handling, parsing, and error reporting; includes ESLint directives in test runner and CAS validation.
Core & DDP Client
packages/core-services/src/lib/mongo.ts, packages/ddp-client/src/MinimalDDPClient.ts, packages/ddp-client/src/types/ClientStream.ts
Adds ESLint directives for MongoDB connection error logging and DDP client documentation examples.
ESLint Config & UI Components
packages/eslint-config/index.js, packages/favicon/src/index.ts, packages/i18n/src/index.ts, packages/livechat/src/lib/connection.ts, packages/livechat/src/lib/hooks.ts, packages/livechat/src/lib/transcript.ts, packages/livechat/src/routes/LeaveMessage/index.tsx, packages/livechat/src/routes/SwitchDepartment/index.tsx, packages/livechat/src/store/index.tsx, packages/livechat/src/widget.ts
Updates ESLint config to warn on console usage; adds console logging throughout livechat widget for error handling, validation, and deprecation warnings.
Message Parser & Models
packages/message-parser/benchmarks/parser.bench.ts, packages/models/src/models/BaseRaw.ts, packages/models/src/models/Roles.ts, packages/models/src/models/Subscriptions.ts, packages/models/src/models/Users.ts
Adds ESLint directives for benchmark logging; adds console.warn for field warnings, index creation failures, role not-found scenarios, and array type coercion in models.
Release & Tracing
packages/release-action/src/getMetadata.ts, packages/tracing/src/index.ts
Adds ESLint directives for error logging in release metadata extraction and untraced method logging.
UI Context & VoIP
packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx, packages/ui-contexts/src/TranslationContext.ts, packages/ui-contexts/src/hooks/useAccountsCustomFields.ts, packages/ui-contexts/src/hooks/useAvailableDevices.ts, packages/ui-contexts/src/hooks/useDeviceConstraints.ts, packages/ui-contexts/src/hooks/useSelectedDevices.ts, packages/ui-contexts/src/hooks/useSetInputMediaDevice.ts, packages/ui-contexts/src/hooks/useSetOutputMediaDevice.ts, packages/ui-voip/src/components/DevicePicker.tsx, packages/ui-voip/src/context/MediaCallLogger.ts, packages/ui-voip/src/context/MediaCallProvider.tsx, packages/ui-voip/src/context/MockedMediaCallProvider.tsx, packages/ui-voip/src/context/useMediaSession.ts, packages/ui-voip/src/context/useMediaSessionInstance.ts, packages/ui-voip/src/context/useMediaStream.ts, packages/ui-voip/src/context/useTonePlayer.ts
Adds console logging for custom fields validation, device context warnings, VoIP device picker warnings, media stream errors, tone player warnings, and call session logging; includes ESLint directives throughout.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The changes are highly repetitive—primarily mechanical replacements of console methods with Logger equivalents across many files. However, the large number of affected files (100+) and variety of contexts require systematic verification to ensure: Logger imports and naming conventions are consistent, all console calls are properly replaced, logic remains unchanged, and ESLint directives are correctly placed. The few files with actual logic changes (like addUserRoles validation and ufs-store public interface additions) add minor complexity.

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% 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 pull request title accurately reflects the primary change: systematically replacing console.* calls with structured @rocket.chat/logger across the codebase. The title is specific, concise, and clearly communicates the main objective.

✏️ 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.

Copy link
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.

4 issues found across 120 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

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="ee/apps/omnichannel-transcript/src/service.ts">

<violation number="1" location="ee/apps/omnichannel-transcript/src/service.ts:36">
P2: Logger.error only accepts a single argument; the second `err` argument here is ignored, so the error/stack is dropped from logs. Log the error object as part of the structured payload instead.</violation>
</file>

<file name="apps/meteor/ee/server/hooks/federation/index.ts">

<violation number="1" location="apps/meteor/ee/server/hooks/federation/index.ts:71">
P2: Logger.error only accepts a single argument; passing the Error as a second argument drops the error object entirely, so stack/err fields are lost in logs.</violation>
</file>

<file name="apps/meteor/app/api/server/api.ts">

<violation number="1" location="apps/meteor/app/api/server/api.ts:88">
P2: Logger.warn only accepts a single payload; passing an Error as a second argument is ignored, so the stack/context is dropped. Use the structured payload form with `err` to capture the exception.</violation>
</file>

<file name="ee/apps/queue-worker/src/service.ts">

<violation number="1" location="ee/apps/queue-worker/src/service.ts:34">
P2: Logger.error only accepts a single argument and forwards it to pino, so passing the error as a second argument is ignored and drops stack/context. Use a structured object so the error is captured.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

res.end('ok');
} catch (err) {
console.error('Service not healthy', err);
logger.error('Service not healthy', err);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 1, 2026

Choose a reason for hiding this comment

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

P2: Logger.error only accepts a single argument; the second err argument here is ignored, so the error/stack is dropped from logs. Log the error object as part of the structured payload instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At ee/apps/omnichannel-transcript/src/service.ts, line 36:

<comment>Logger.error only accepts a single argument; the second `err` argument here is ignored, so the error/stack is dropped from logs. Log the error object as part of the structured payload instead.</comment>

<file context>
@@ -31,7 +33,7 @@ void (async () => {
 				res.end('ok');
 			} catch (err) {
-				console.error('Service not healthy', err);
+				logger.error('Service not healthy', err);
 
 				res.writeHead(500);
</file context>
Suggested change
logger.error('Service not healthy', err);
logger.error({ err, msg: 'Service not healthy' });
Fix with Cubic

} catch (error) {
// Log the error but don't prevent the message from being sent locally
console.error('[sendMessage] Failed to send message to Native Federation:', error);
logger.error('[sendMessage] Failed to send message to Native Federation:', error);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 1, 2026

Choose a reason for hiding this comment

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

P2: Logger.error only accepts a single argument; passing the Error as a second argument drops the error object entirely, so stack/err fields are lost in logs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/ee/server/hooks/federation/index.ts, line 71:

<comment>Logger.error only accepts a single argument; passing the Error as a second argument drops the error object entirely, so stack/err fields are lost in logs.</comment>

<file context>
@@ -66,7 +68,7 @@ callbacks.add(
 		} catch (error) {
 			// Log the error but don't prevent the message from being sent locally
-			console.error('[sendMessage] Failed to send message to Native Federation:', error);
+			logger.error('[sendMessage] Failed to send message to Native Federation:', error);
 		}
 	},
</file context>
Suggested change
logger.error('[sendMessage] Failed to send message to Native Federation:', error);
logger.error({ err: error, msg: '[sendMessage] Failed to send message to Native Federation:' });
Fix with Cubic

API.v1.setLimitedCustomFields(nonPublicCustomFields);
} catch (error) {
console.warn('Invalid Custom Fields', error);
logger.warn('Invalid Custom Fields', error);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 1, 2026

Choose a reason for hiding this comment

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

P2: Logger.warn only accepts a single payload; passing an Error as a second argument is ignored, so the stack/context is dropped. Use the structured payload form with err to capture the exception.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/app/api/server/api.ts, line 88:

<comment>Logger.warn only accepts a single payload; passing an Error as a second argument is ignored, so the stack/context is dropped. Use the structured payload form with `err` to capture the exception.</comment>

<file context>
@@ -85,7 +85,7 @@ settings.watch<string>('Accounts_CustomFields', (value) => {
 		API.v1.setLimitedCustomFields(nonPublicCustomFields);
 	} catch (error) {
-		console.warn('Invalid Custom Fields', error);
+		logger.warn('Invalid Custom Fields', error);
 	}
 });
</file context>
Suggested change
logger.warn('Invalid Custom Fields', error);
logger.warn({ msg: 'Invalid Custom Fields', err: error });
Fix with Cubic

res.end('ok');
} catch (err) {
console.error('Service not healthy', err);
logger.error('Service not healthy', err);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 1, 2026

Choose a reason for hiding this comment

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

P2: Logger.error only accepts a single argument and forwards it to pino, so passing the error as a second argument is ignored and drops stack/context. Use a structured object so the error is captured.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At ee/apps/queue-worker/src/service.ts, line 34:

<comment>Logger.error only accepts a single argument and forwards it to pino, so passing the error as a second argument is ignored and drops stack/context. Use a structured object so the error is captured.</comment>

<file context>
@@ -29,7 +31,7 @@ void (async () => {
 				res.end('ok');
 			} catch (err) {
-				console.error('Service not healthy', err);
+				logger.error('Service not healthy', err);
 
 				res.writeHead(500);
</file context>
Suggested change
logger.error('Service not healthy', err);
logger.error({ err, msg: 'Service not healthy' });
Fix with Cubic

Copy link
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: 6

Note

Due to the large number of review comments, Critical severity comments were prioritized as inline comments.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
apps/meteor/app/smarsh-connector/server/functions/generateEml.ts (1)

1-12: ⚠️ Potential issue | 🟡 Minor

Unused Logger import and instance.

The Logger import and logger variable are declared but never used in any active code path. The only reference to logger is on line 110 inside a commented-out block. This will likely trigger unused import/variable warnings.

Either remove the logger setup since there are no active console.* calls to replace in this file, or if the intent is to enable the debug logging at line 110, uncomment that code block.

Option 1: Remove unused logger
-import { Logger } from '@rocket.chat/logger';
 import { MessageTypes } from '@rocket.chat/message-types';
 import { Messages, SmarshHistory, Users, Rooms } from '@rocket.chat/models';
 import { Meteor } from 'meteor/meteor';
 import moment from 'moment-timezone';

 import { sendEmail } from './sendEmail';
 import { i18n } from '../../../../server/lib/i18n';
 import { settings } from '../../../settings/server';

-const logger = new Logger('SmarshConnector:GenerateEml');
-
 const start =
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/smarsh-connector/server/functions/generateEml.ts` around
lines 1 - 12, The file imports Logger and creates a logger constant (Logger,
logger) but never uses it; either remove the unused import and the const logger
declaration from generateEml.ts to eliminate the warning, or re-enable the
intended debug log by uncommenting the logging call where logger is referenced
(the commented block around the previous logger.debug/logger.error usage) so the
logger is actually used; ensure you update the import list accordingly and run
lint to confirm the unused-variable warning is resolved.
packages/api-client/src/index.ts (1)

97-104: ⚠️ Potential issue | 🟠 Major

Behavioral change: Downgrading from error to warning may cause silent failures.

The original code threw an error to prevent malformed URLs. Now it only warns and continues, which can produce invalid URLs like /endpoint?existingParam?newParam=value (two ? characters) when both the endpoint contains a query string and params are provided.

If the intent is purely to migrate logging, consider keeping the throw or at least returning early after the warning. Otherwise, this will silently send malformed requests that are difficult to debug.

Option A: Restore fail-fast behavior with structured logging (preferred)
 	if (/\?/.test(endpoint)) {
-		// eslint-disable-next-line no-console
-		console.warn('Endpoint cannot contain query string', endpoint);
+		throw new Error(`Endpoint cannot contain query string: ${endpoint}`);
 	}
Option B: Warn and return early to avoid malformed URL

If throwing is undesirable, consider returning early or stripping params:

 	if (/\?/.test(endpoint)) {
 		// eslint-disable-next-line no-console
 		console.warn('Endpoint cannot contain query string', endpoint);
+		const response = await this.send(endpoint, 'GET', options ?? {});
+		return response.json();
 	}
-	const queryParams = this.getParams(params);
-	const response = await this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', options ?? {});
+	const queryParams = this.getParams(params);
+	const response = await this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', options ?? {});

Based on learnings: In this codebase, fail-fast behavior is preferred over defensive defaults that hide problems.

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

In `@packages/api-client/src/index.ts` around lines 97 - 104, The current change
downgraded a thrown error to a console.warn when an endpoint already contains a
query string, which can cause malformed URLs when later appending
this.getParams(params) and calling this.send; restore fail-fast behavior by
throwing an Error (e.g., throw new Error('Endpoint cannot contain query string:
' + endpoint)) where the console.warn is now, so the request building (the
template using endpoint and queryParams before calling this.send and
response.json()) never proceeds with an invalid URL; ensure the thrown error
includes the endpoint value for debugging.
ee/apps/ddp-streamer/src/DDPStreamer.ts (1)

241-246: ⚠️ Potential issue | 🟠 Major

Logger.error signature mismatch — error context lost.

logger.error accepts a single argument, but two are passed. The err object won't be logged.

Proposed fix
-					logger.error('Service not healthy', err);
+					logger.error({ msg: 'Service not healthy', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/ddp-streamer/src/DDPStreamer.ts` around lines 241 - 246, In the catch
block inside DDPStreamer.ts where logger.error is called, the logger.error
signature accepts a single argument so the current call logger.error('Service
not healthy', err) drops the err; change the call to pass a single string that
includes the error details (e.g., interpolate or format the err.stack/message
into the message) so the error context is logged—update the catch in the
relevant async handler/function to call logger.error with one composed argument
and keep the existing res.writeHead(500); res.end('not healthy'); flow.
apps/meteor/server/ufs/ufs-store.ts (1)

308-330: ⚠️ Potential issue | 🟠 Major

Second argument to logger.error() is silently ignored.

The Logger.error() method accepts only one parameter (msg: object | string), but these three methods pass two arguments. The error object containing the stack trace will be discarded. To preserve error context in structured logs, pass an object with both message and error:

🔧 Proposed fix
 onCopyError(err: Error, fileId: string, _file: IUpload) {
-	logger.error(`ufs: cannot copy file "${fileId}" (${err.message})`, err);
+	logger.error({ msg: `ufs: cannot copy file "${fileId}" (${err.message})`, err });
 }

 onReadError(err: Error, fileId: string, _file: IUpload) {
-	logger.error(`ufs: cannot read file "${fileId}" (${err.message})`, err);
+	logger.error({ msg: `ufs: cannot read file "${fileId}" (${err.message})`, err });
 }

 onWriteError(err: Error, fileId: string, _file: IUpload) {
-	logger.error(`ufs: cannot write file "${fileId}" (${err.message})`, err);
+	logger.error({ msg: `ufs: cannot write file "${fileId}" (${err.message})`, err });
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/server/ufs/ufs-store.ts` around lines 308 - 330, The three
handlers onCopyError, onReadError, and onWriteError call logger.error with two
arguments (a string and an Error) but Logger.error accepts a single msg
parameter, so the Error is dropped; change each call to pass a single object (or
formatted string) that includes both the message and the error (e.g., { msg:
`ufs: cannot ... "${fileId}"`, err }) so the stack/metadata is preserved when
calling logger.error in onCopyError, onReadError, and onWriteError.
🟠 Major comments (24)
apps/meteor/app/apps/server/bridges/details.ts-14-14 (1)

14-14: ⚠️ Potential issue | 🟠 Major

appId context is silently dropped.

The Logger.warn method signature (from @rocket.chat/logger) is warn(msg: object | string): void — it accepts only one argument. The second argument appId will be ignored, losing valuable diagnostic context.

🛠️ Proposed fix: include appId in the message
-		const logFailure = () => logger.warn('failed to notify about the setting change.', appId);
+		const logFailure = () => logger.warn({ msg: 'failed to notify about the setting change.', appId });

Alternatively, use a template literal:

-		const logFailure = () => logger.warn('failed to notify about the setting change.', appId);
+		const logFailure = () => logger.warn(`failed to notify about the setting change. appId: ${appId}`);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/apps/server/bridges/details.ts` at line 14, The log call in
logFailure uses logger.warn('failed to notify about the setting change.', appId)
but `@rocket.chat/logger.warn` accepts a single argument so appId is dropped;
update the log to include appId in the single message argument (for example by
embedding appId into the message string or passing an object with message and
appId) so the warning retains the appId context when logging from logFailure and
ensure you modify the call site using logger.warn accordingly.
apps/meteor/ee/server/local-services/instance/service.ts-194-194 (1)

194-194: ⚠️ Potential issue | 🟠 Major

Error context is silently dropped due to incorrect Logger.error usage.

The Logger.error method accepts a single argument (msg: object | string), but this call passes two arguments. The error object will be ignored, losing valuable error context in logs.

Follow the pattern used at line 141 with SystemLogger.error:

-			logger.error('Instance service did not start correctly', error);
+			logger.error({ msg: 'Instance service did not start correctly', err: error });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/ee/server/local-services/instance/service.ts` at line 194, The
current call to logger.error('Instance service did not start correctly', error)
passes two args so the error object is dropped; update the call to pass a single
object like the pattern used with SystemLogger.error (e.g., logger.error({ msg:
'Instance service did not start correctly', error })) so the error details are
included in logs; locate the logger.error call in service.ts and replace the
two-argument invocation accordingly.
apps/meteor/ee/server/startup/presence.ts-49-51 (1)

49-51: ⚠️ Potential issue | 🟠 Major

Second argument to logger.error is silently dropped.

The Logger.error method signature is error(msg: object | string): void — it accepts only one argument. The err object passed as the second argument will be ignored, losing the actual error details in logs.

Pass the error as part of a structured object or interpolate it into the message string:

Proposed fix
 void Presence.updateConnection(login.user._id, login.connection.id).catch((err) => {
-  logger.error('Error updating connection presence on heartbeat:', err);
+  logger.error({ msg: 'Error updating connection presence on heartbeat', err });
 });

Alternatively, use string interpolation:

-  logger.error('Error updating connection presence on heartbeat:', err);
+  logger.error(`Error updating connection presence on heartbeat: ${err}`);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/ee/server/startup/presence.ts` around lines 49 - 51, The current
logger.error call drops the error because Logger.error only accepts one
argument; update the error logging in the Presence.updateConnection catch block
(where Presence.updateConnection(login.user._id, login.connection.id) is called)
to pass a single structured object or interpolated string that includes the
error (e.g., include the error under an "err" or "error" key along with context
like userId and connectionId) so the actual error details are not lost.
packages/ui-voip/src/context/useMediaStream.ts-18-19 (1)

18-19: ⚠️ Potential issue | 🟠 Major

Replace console.error + lint bypass with the VoIP logger.

Line 18/42 reintroduce raw console logging via eslint-disable-next-line no-console. That bypasses the new lint guard and keeps these errors unstructured. Please use the package logger (MediaCallLogger) for both paths and drop the inline comments.

Proposed fix
 import { useSafeRefCallback } from '@rocket.chat/fuselage-hooks';
 import type { MediaSignalingSession } from '@rocket.chat/media-signaling';
 import { useCallback, useRef } from 'react';
+import MediaCallLogger from './MediaCallLogger';
@@
 	} catch (error) {
-		// eslint-disable-next-line no-console
-		console.error('MediaCall: useMediaStream - Error getting remote media stream', error);
+		MediaCallLogger.error({ err: error }, 'MediaCall: useMediaStream - Error getting remote media stream');
 		return null;
 	}
 };
@@
 					node.srcObject = remoteStream.stream;
 					node.play().catch((error) => {
-						// eslint-disable-next-line no-console
-						console.error('MediaCall: useMediaStream - Error playing media stream', error);
+						MediaCallLogger.error({ err: error }, 'MediaCall: useMediaStream - Error playing media stream');
 					});

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

Also applies to: 42-43

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

In `@packages/ui-voip/src/context/useMediaStream.ts` around lines 18 - 19, Replace
the raw console.error calls (and remove the inline eslint-disable-next-line
no-console comments) in the useMediaStream hook with the package logger: call
MediaCallLogger.error with the same descriptive message and include the caught
error object so the error is structured and searchable; update both error paths
referenced in the diff (the error when getting the remote media stream and the
other error path around line ~42) to use MediaCallLogger.error instead of
console.error.
packages/apps-engine/src/client/AppClientManager.ts-25-26 (1)

25-26: ⚠️ Potential issue | 🟠 Major

Remove ad-hoc console logging from this production path.

load() now logs enabled apps via console.log and bypasses lint with an inline disable. That regresses the no-console direction of this PR and introduces avoidable runtime noise. Please remove both lines (or switch to structured logger in a dedicated follow-up where dependency wiring is available).

Suggested minimal fix
-		// eslint-disable-next-line no-console
-		console.log('Enabled apps:', this.apps);

As per coding guidelines: **/*.{ts,tsx,js}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/apps-engine/src/client/AppClientManager.ts` around lines 25 - 26,
Remove the ad-hoc console logging in AppClientManager: delete the two lines that
call console.log('Enabled apps:', this.apps) and the preceding
eslint-disable-next-line no-console so the production load path no longer emits
runtime console noise; if structured logging is required later, add it via the
project's logger in a follow-up, but for now remove those two lines from the
load() flow in class AppClientManager (the place referencing this.apps).
packages/apps-engine/src/server/accessors/LivechatRead.ts-19-22 (1)

19-22: ⚠️ Potential issue | 🟠 Major

Avoid per-call deprecation warnings and inline eslint suppression in runtime path.

Line 20 warns on every invocation, which can flood production logs; Line 19 adds an implementation comment to bypass no-console. Emit this deprecation warning once instead.

Proposed fix
+let hasWarnedIsOnlineDeprecation = false;
+
 export class LivechatRead implements ILivechatRead {
 	constructor(
 		private readonly livechatBridge: LivechatBridge,
 		private readonly appId: string,
 	) {}

@@
 	public isOnline(departmentId?: string): boolean {
-		// eslint-disable-next-line no-console
-		console.warn(
-			"The `LivechatRead.isOnline` method is deprecated and won't behave as intended. Please use `LivechatRead.isOnlineAsync` instead",
-		);
+		if (!hasWarnedIsOnlineDeprecation) {
+			hasWarnedIsOnlineDeprecation = true;
+			console.warn(
+				"The `LivechatRead.isOnline` method is deprecated and won't behave as intended. Please use `LivechatRead.isOnlineAsync` instead",
+			);
+		}

 		return this.livechatBridge.doIsOnline(departmentId, this.appId);
 	}
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/apps-engine/src/server/accessors/LivechatRead.ts` around lines 19 -
22, The per-call console.warn in LivechatRead.isOnline (and its inline
eslint-disable comment) should be changed to emit the deprecation warning only
once: add a module-level boolean (e.g., deprecationWarned) and, inside
LivechatRead.isOnline, check and set it so console.warn is called a single time,
then remove the inline eslint-disable comment; keep the message text the same
and consider using the project logger if available, but the core change is to
guard the existing console.warn with a one-time flag so it no longer floods logs
on every invocation and delete the inline eslint suppression.
packages/models/src/models/BaseRaw.ts-36-42 (1)

36-42: ⚠️ Potential issue | 🟠 Major

Remove eslint-disable comments and use structured logging instead of console.warn

These changes reintroduce console.warn with inline eslint-disable comments (lines 39–40, 102–103, 130) that violate the coding guideline to avoid code comments in implementation. However, @rocket.chat/logger is not currently a dependency of packages/models, so the proposed structured logger approach requires first adding that dependency to this package's package.json.

Either:

  1. Add @rocket.chat/logger as a dependency to packages/models and refactor these three catch blocks to use structured logging, or
  2. If that dependency is not appropriate for this layer, apply an alternative solution that removes the eslint-disable comments and follows the no-console lint rule.

Also applies to lines 102–103 and 130.

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

In `@packages/models/src/models/BaseRaw.ts` around lines 36 - 42, Add
`@rocket.chat/logger` to packages/models dependencies and replace direct
console.warn usages in BaseRaw.ts: import the logger (e.g., import { logger }
from '@rocket.chat/logger') and change the warnFields implementation and the
three catch blocks that currently call console.warn (the warnFields constant and
the two other catch sites referenced) to call logger.warn with a structured
message and metadata (include error/stack and contextual fields). Remove the
eslint-disable comments after switching to logger.warn so no console.* calls
remain in this file.
apps/meteor/app/api/server/lib/MultipartUploadHandler.ts-44-46 (1)

44-46: ⚠️ Potential issue | 🟠 Major

Logger method signature mismatch — error context will be lost.

The Logger.warn method only accepts a single msg: object | string parameter. The second argument (error) will be silently ignored, losing the error details that are critical for debugging cleanup failures.

To preserve the error context, pass an object with both the message and error:

🐛 Proposed fix
 		} catch (error: any) {
-			logger.warn(`[UploadService] Failed to cleanup temp file: ${tempFilePath}`, error);
+			logger.warn({ msg: `Failed to cleanup temp file: ${tempFilePath}`, error });
 		}

Note: The [UploadService] prefix can be removed since the logger is already instantiated with 'Api:MultipartUploadHandler' context.

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

In `@apps/meteor/app/api/server/lib/MultipartUploadHandler.ts` around lines 44 -
46, The catch block in MultipartUploadHandler uses logger.warn(`[UploadService]
Failed to cleanup temp file: ${tempFilePath}`, error) which loses the error
because logger.warn accepts a single msg parameter; update the catch to call
logger.warn with a single object containing both message and error (e.g., { msg:
`Failed to cleanup temp file: ${tempFilePath}`, err: error }) so the error
context is preserved; use the existing logger context (remove the
`[UploadService]` prefix) and ensure you update the catch surrounding
tempFilePath and any similar cleanup logging to follow the same pattern.
ee/apps/ddp-streamer/src/Client.ts-84-86 (1)

84-86: ⚠️ Potential issue | 🟠 Major

Logger.error signature mismatch — error context lost.

logger.error accepts a single argument. The err object passed as the second argument will be ignored.

Proposed fix
-				logger.error('Error updating connection presence:', err);
+				logger.error({ msg: 'Error updating connection presence', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/ddp-streamer/src/Client.ts` around lines 84 - 86, The call in the
Presence.updateConnection(this.userId, this.connection.id).catch handler passes
the error as a second argument to logger.error which only accepts one argument,
so the error context is lost; update the catch to pass a single value that
includes both a descriptive message and the error (e.g., a single object or a
formatted string) — reference the Promise returned by Presence.updateConnection
and replace logger.error('Error updating connection presence:', err) with a
single-argument call such as logger.error({ message: 'Error updating connection
presence', userId: this.userId, connectionId: this.connection.id, err }) or a
formatted string that includes String(err) so the error details are preserved.
ee/apps/ddp-streamer/src/DDPStreamer.ts-265-267 (1)

265-267: ⚠️ Potential issue | 🟠 Major

Logger.error signature mismatch — startup error context lost.

Same issue: the err object is passed as a second argument and will be ignored.

Proposed fix
-			logger.error('DDPStreamer did not start correctly', err);
+			logger.error({ msg: 'DDPStreamer did not start correctly', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/ddp-streamer/src/DDPStreamer.ts` around lines 265 - 267, In the
DDPStreamer startup catch block, the call logger.error('DDPStreamer did not
start correctly', err) passes the error as a second argument which gets ignored;
update the call in DDPStreamer to pass the error as structured data or include
its message/stack in the first argument (for example use logger.error({ err },
'DDPStreamer did not start correctly') or include err.message/err.stack in the
log string) so the actual error context is preserved.
ee/apps/ddp-streamer/src/Client.ts-119-121 (1)

119-121: ⚠️ Potential issue | 🟠 Major

Logger.error signature mismatch — error context lost.

Same issue: the err object is passed as a second argument and will be ignored.

Proposed fix
-			logger.error('Unexpected error:', err);
+			logger.error({ msg: 'Unexpected error', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/ddp-streamer/src/Client.ts` around lines 119 - 121, The error handler
for this.ws uses logger.error('Unexpected error:', err) which drops the error
because the logger expects a single message or an object; update the handler in
Client (the this.ws.on('error', ...) block) to pass the error as structured
context or include its message/stack in the single logger call (e.g.,
logger.error({ err }, 'Unexpected error') or logger.error(`Unexpected error:
${err.stack || err}`)), keeping the subsequent
this.ws.close(WS_ERRORS.CLOSE_PROTOCOL_ERROR,
WS_ERRORS_MESSAGES.CLOSE_PROTOCOL_ERROR) invocation unchanged.
ee/apps/ddp-streamer/src/Streamer.ts-91-102 (1)

91-102: ⚠️ Potential issue | 🟠 Major

Logger method signature mismatch and potential log level consideration.

Two issues in this catch block:

  1. Line 101: logger.error accepts a single argument, but two are passed. The error object will be ignored.

  2. Based on learnings from a similar module (apps/meteor/server/modules/streamer/streamer.module.ts), per-subscription delivery failures intentionally use debug level to keep logs less noisy. Consider whether error level is appropriate here or if debug would be more consistent.

Proposed fix for signature issue
 			} catch (error: any) {
 				if (error.code === 'ERR_STREAM_DESTROYED') {
 					logger.warn('Trying to send data to destroyed stream, closing connection.');

 					// if we still tried to send data to a destroyed stream, we'll try again to close the connection
 					if (subscription.client.ws.readyState !== WebSocket.OPEN) {
 						subscription.stop();
 						subscription.client.ws.close();
 					}
 				}
-				logger.error('Error trying to send data to stream.', error);
+				logger.error({ msg: 'Error trying to send data to stream.', error });
 			}

Based on learnings: "In apps/meteor/server/modules/streamer/streamer.module.ts, the catch block in sendToManySubscriptions intentionally uses SystemLogger.debug (not error or warn) for per-subscription delivery failures to keep logs less noisy."

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

In `@ee/apps/ddp-streamer/src/Streamer.ts` around lines 91 - 102, The catch block
handling send failures (in the catch for send to subscription in Streamer.ts)
currently calls logger.error with two args (logger.error('Error trying to send
data to stream.', error)) which loses the error object and uses a noisy log
level; change this to a single-argument log that preserves the error details and
demote the level to debug to match per-subscription delivery behavior (e.g., use
logger.debug and include error.message/stack in the single formatted log
string). Keep the existing ERR_STREAM_DESTROYED branch and
subscription.stop/close behavior intact.
ee/apps/ddp-streamer/src/configureServer.ts-23-23 (1)

23-23: ⚠️ Potential issue | 🟠 Major

Logger.error signature mismatch — error object will be ignored.

The Logger.error method accepts a single object | string argument, but two arguments are passed here. The err parameter will be silently ignored, losing error context. Pass the error as a property within an object instead.

Proposed fix
-	.catch((err) => logger.error('DDPStreamer not able to retrieve login services configuration', err));
+	.catch((err) => logger.error({ msg: 'DDPStreamer not able to retrieve login services configuration', err }));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/ddp-streamer/src/configureServer.ts` at line 23, The catch handler
passes two arguments to logger.error so the error object is dropped; update the
catch in configureServer.ts (the .catch((err) => logger.error(...)) callback) to
call logger.error with a single object that includes the message and the err
(e.g., { message: 'DDPStreamer not able to retrieve login services
configuration', err }) so the error context is preserved; keep the same message
text but wrap it and the captured err into one object for logger.error.
ee/apps/presence-service/src/service.ts-34-34 (1)

34-34: ⚠️ Potential issue | 🟠 Major

Pass error as structured object to preserve error context.

The Logger.error() method accepts only a single parameter (msg: object | string), so the err argument will be silently dropped. This loses critical error information when the health check fails.

Suggested fix
-				logger.error('Service not healthy', err);
+				logger.error({ msg: 'Service not healthy', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/presence-service/src/service.ts` at line 34, The logger.error call
currently passes two arguments (logger.error('Service not healthy', err)) which
drops the error; update the call to pass a single structured object so the error
is preserved (e.g., logger.error({ message: 'Service not healthy', error: err
})) and, if available, include err.stack or a serialized form; change the
invocation in service.ts (the logger.error call handling the service health
check) to pass that single object.
ee/packages/federation-matrix/src/helpers/createOrUpdateFederatedUser.ts-14-15 (1)

14-15: ⚠️ Potential issue | 🟠 Major

Remove this production console.log and its lint bypass.

Lines [14-15] add unstructured console logging of user payload in a hot server path. This should not be introduced in production flow.

Proposed change
-	// eslint-disable-next-line no-console
-	console.log('createOrUpdateFederatedUser ->', options);

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

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

In `@ee/packages/federation-matrix/src/helpers/createOrUpdateFederatedUser.ts`
around lines 14 - 15, Remove the production console.log and the accompanying
eslint-disable comment in createOrUpdateFederatedUser (the
console.log('createOrUpdateFederatedUser ->', options) lines); either delete
them or replace with a call to the project's structured logger (e.g.,
processLogger or logger) at debug/trace level and avoid logging the full user
payload—log only minimal, non-sensitive identifiers (or a redacted subset) if
telemetry is required; ensure you remove the no-console bypass and use the
existing logging utility used elsewhere in the module/function.
packages/apps-engine/src/server/AppManager.ts-297-300 (1)

297-300: ⚠️ Potential issue | 🟠 Major

Remove inline eslint-disable-next-line comments and replace raw console.* calls with appropriate logging or error handling.

Lines 297–300, 498–500, 525–527, 951–953, 1149–1151, 1163–1164, and 1243–1245 contain inline ESLint suppression comments, which violates the coding guideline: "Avoid code comments in the implementation" (per **/*.{ts,tsx,js}).

However, the proposed fix referencing @rocket.chat/logger is not viable—this package is not a dependency of packages/apps-engine. Before proceeding, clarify the intended logging strategy:

  1. Should @rocket.chat/logger be added as a new dependency to apps-engine?
  2. Should these console calls be removed entirely or replaced with a different logging mechanism?
  3. If this is a style-only cleanup, consider deferring to a follow-up PR to keep scope tight and avoid introducing new dependencies in this PR.

Address the comment violations directly rather than suppressing the linter.

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

In `@packages/apps-engine/src/server/AppManager.ts` around lines 297 - 300, Remove
the inline eslint-disable comments and replace raw console calls in AppManager
with a proper logging or error-handling approach: locate the
console.warn/console.error usages around the AppManager methods that reference
item.info.name, item.id and variable e and replace them with calls to an
injectable logger (e.g., this.logger.warn/this.logger.error) or with
throwing/propagating the error if no logger exists; do not add
`@rocket.chat/logger` inside this PR—instead either use an existing logger passed
into AppManager (add a constructor param or setter if missing) or remove the
console calls and rethrow the error, and if you decide a new dependency is
needed open a follow-up PR to add it and wire it into AppManager.
ee/packages/federation-matrix/src/events/ping.ts-5-6 (1)

5-6: ⚠️ Potential issue | 🟠 Major

Use Logger instead of console.log, consistent with other event handlers in this package.

All other event files in federation-matrix (edu.ts, member.ts, message.ts, reaction.ts) already use @rocket.chat/logger. The Logger import and dependency are available to federation-matrix; ping.ts should follow the same pattern.

Rewrite using Logger (pattern from other event files)
+import { Logger } from '@rocket.chat/logger';
 import { federationSDK } from '@rocket.chat/federation-sdk';
 
+const logger = new Logger('federation-matrix:ping');
+
 export const ping = async () => {
 	federationSDK.eventEmitterService.on('homeserver.ping', async (data) => {
-		// eslint-disable-next-line no-console
-		console.log('Message received from homeserver', data);
+		logger.debug('Message received from homeserver', data);
 	});
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/packages/federation-matrix/src/events/ping.ts` around lines 5 - 6, Replace
the console.log call in ping.ts with the package logger used by other event
handlers: import Logger from '@rocket.chat/logger' (or use the same logger
instance name used elsewhere, e.g., "logger") and call logger.debug/info with
the same message and data instead of console.log; remove the
eslint-disable-next-line no-console and ensure the log call follows the same
pattern as in edu.ts/member.ts/message.ts/reaction.ts so the event handler uses
the shared Logger instance.
packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts-615-615 (1)

615-615: ⚠️ Potential issue | 🟠 Major

Avoid logging raw subprocess payloads and stderr content.

At Line 615 and Line 727 (plus related error paths), full payload/chunk logging can expose sensitive data from apps/runtime. Log sanitized metadata instead (appId, method, request id, byte length, error type/message).

🔒 Minimal sanitization direction
- console.log('SUBPROCESS LOG', message);
+ this.debug(
+   '[%s] subprocess log method=%s id=%s',
+   this.getAppId(),
+   message.payload.method,
+   'id' in message.payload ? String(message.payload.id) : 'n/a',
+ );

- console.error('Subprocess stderr', chunk.toString());
+ this.debug('[%s] subprocess stderr parse failure (bytes=%d)', this.getAppId(), chunk.length);

Also applies to: 686-687, 693-695, 710-710, 726-727

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

In `@packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts` at
line 615, Replace raw console.log of subprocess payloads in
AppsEngineDenoRuntime (where it currently logs the variable "message" and other
raw chunks) with sanitized logging: extract and log only metadata such as appId,
method/name, requestId (if present), byte length of payload, and for errors log
error type and message; do this in the message handler and the related
error/stream-chunk handlers (the spots currently printing "message" and raw
chunks) so no full payload or stderr content is written to logs by the class
AppsEngineDenoRuntime or its subprocess message/error handlers.
packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts-67-68 (1)

67-68: ⚠️ Potential issue | 🟠 Major

Stop bypassing no-console in runtime code with inline suppressions.

These additions reintroduce console.* across production runtime paths and bypass the lint guard with inline eslint-disable comments. Please route these branches through the existing structured/runtime logging path in this package and remove the inline suppressions.

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

Also applies to: 201-202, 432-433, 614-615, 622-623, 685-687, 693-695, 699-700, 704-705, 709-710, 714-715, 726-727

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

In `@packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts` around
lines 67 - 68, The code uses inline eslint-disable and direct console.* calls in
AppsEngineDenoRuntime (e.g., the negative APPS_ENGINE_RUNTIME_TIMEOUT message)
which violates runtime logging rules; remove the inline suppressions and replace
each console.* call with the package's structured runtime logger used elsewhere
in AppsEngineDenoRuntime (e.g., use the class logger instance or the existing
runtime logging helper such as this.logger/this.getLogger()/runtimeLogger) at
the appropriate level (warn/error/info), keep the original messages, and update
all reported locations (67-68, 201-202, 432-433, 614-615, 622-623, 685-687,
693-695, 699-700, 704-705, 709-710, 714-715, 726-727) to use that logger instead
of console.
ee/packages/network-broker/src/index.ts-148-150 (1)

148-150: ⚠️ Potential issue | 🟠 Major

Remove console.log and eslint-disable comment from broker startup hook.

Line 149 adds an inline ESLint bypass and Line 150 uses console.log in production code. This regresses the PR's structured-logging objective and bypasses the re-enabled no-console protection. The inline comment also violates the repository's coding guideline to avoid code comments in implementation.

🔧 Proposed fix
 import { isMeteorError, MeteorError } from '@rocket.chat/core-services';
+import { Logger } from '@rocket.chat/logger';
 import EJSON from 'ejson';
 import type Moleculer from 'moleculer';
 import { Errors, Serializers, ServiceBroker } from 'moleculer';
 import { pino } from 'pino';
 
 import { NetworkBroker } from './NetworkBroker';
+
+const logger = new Logger('NetworkBroker');
@@
 		errorRegenerator: new CustomRegenerator(),
 		started(): void {
-			// eslint-disable-next-line no-console
-			console.log('NetworkBroker started successfully.');
+			logger.info('NetworkBroker started successfully.');
 		},
 		...options,
 	});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/packages/network-broker/src/index.ts` around lines 148 - 150, Remove the
inline ESLint disable and console.log in the started() hook; replace them with a
structured log call using the module's logger (e.g., call
this.logger.info('NetworkBroker started successfully.') or
processLogger.info(...) depending on which logger instance is used in this
module) so the message uses the project's structured-logging facility instead of
console.log; ensure you import or reference the correct logger instance and
remove the eslint-disable comment and console.log statement from started().
packages/cas-validate/src/validate.ts-289-291 (1)

289-291: ⚠️ Potential issue | 🟠 Major

Do not log raw CAS response payloads in this error path.

Line 291 logs the full CAS response body, which can contain user identifiers and attributes. This introduces sensitive-data leakage risk.

Proposed fix
 				// The response was not in any expected format, error
 				callback(new Error('Bad response format.'));
-				// eslint-disable-next-line no-console
-				console.error(response);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cas-validate/src/validate.ts` around lines 289 - 291, The code
currently prints the entire CAS response object (console.error(response)) right
after calling callback(new Error('Bad response format.')), which risks leaking
sensitive user attributes; remove the direct logging of the response variable
and instead, if telemetry is required, log only non-sensitive metadata derived
from response (e.g., response.status or a truncated/error code) or a sanitized
error message; update the code around the callback(...) /
console.error(response) usage in validate.ts to stop printing the raw response
and replace it with a safe, minimal log or no log at all.
apps/meteor/server/startup/migrations/v312.ts-18-19 (1)

18-19: ⚠️ Potential issue | 🟠 Major

Narrow unknown before passing to logger.warn.

Line 19 passes error (type unknown) directly to logger.warn(msg: object | string). The unknown type must be narrowed before assignment to a more specific type. This pattern is already used elsewhere in the codebase (e.g., apps/meteor/server/services/video-conference/service.ts:391).

Proposed fix
 		} catch (error: unknown) {
 			logger.warn('Error dropping redundant indexes, continuing...');
-			logger.warn(error);
+			logger.warn(error instanceof Error ? { err: error, message: error.message } : String(error));
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/server/startup/migrations/v312.ts` around lines 18 - 19, The code
passes an unknown `error` directly to `logger.warn`; narrow `error` before
logging by checking its type (e.g., if (error instanceof Error)
logger.warn(error.message, { stack: error.stack }) else if (typeof error ===
'string') logger.warn(error) else logger.warn(String(error)); update the `v312`
migration where `logger.warn('Error dropping redundant indexes, continuing...')`
and `logger.warn(error)` are called to use this narrowed/serialized form so the
call matches logger.warn(msg: object | string) and mirrors the pattern used in
`apps/meteor/server/services/video-conference/service.ts`.
ee/apps/account-service/src/service.ts-34-34 (1)

34-34: ⚠️ Potential issue | 🟠 Major

Error object won't be logged—Logger.error accepts only one argument.

The Logger.error method signature is error(msg: object | string): void. The err parameter passed as the second argument will be silently ignored, losing valuable error context for debugging health check failures.

Pass the error as part of a structured object:

Proposed fix
-			logger.error('Service not healthy', err);
+			logger.error({ msg: 'Service not healthy', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/account-service/src/service.ts` at line 34, The call to logger.error
in service.ts currently passes two arguments so the error object is dropped;
update the logger.error invocation that currently reads logger.error('Service
not healthy', err) to pass a single structured object (e.g., include the message
and the err under a property) so the error details are logged, ensuring you
reference the same logger.error call and the err variable in the surrounding
health-check logic.
packages/models/src/models/Roles.ts-176-178 (1)

176-178: ⚠️ Potential issue | 🟠 Major

Do not reintroduce raw console in production model code.

This adds a new console.log plus lint bypass in the failure path, which conflicts with this PR’s migration objective and weakens the no-console guardrail.

🔧 Suggested fix
-			// eslint-disable-next-line no-console
-			console.log('Role not found', _id, name);
-			throw new Error('Role not found');
+			throw new Error(`Role not found: id=${_id}, name=${name}`);

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/models/src/models/Roles.ts` around lines 176 - 178, Remove the raw
console.log and eslint-disable and replace it with the project's logger (e.g.,
processLogger.error or the module-scoped logger) in the Roles model failure
path: log a clear error including the _id and name variables, then throw the
Error (optionally with a concise message); update the code around the
Role-not-found branch in Roles.ts (the block that currently logs 'Role not
found' for _id and name) to use logger.error instead of console and remove lint
bypass.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c30636 and 74e7a95.

📒 Files selected for processing (120)
  • apps/meteor/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/api.ts
  • apps/meteor/app/api/server/helpers/getUserInfo.ts
  • apps/meteor/app/api/server/lib/MultipartUploadHandler.ts
  • apps/meteor/app/api/server/v1/commands.ts
  • apps/meteor/app/api/server/v1/e2e.ts
  • apps/meteor/app/api/server/v1/rooms.ts
  • apps/meteor/app/apps/server/bridges/details.ts
  • apps/meteor/app/apps/server/bridges/livechat.ts
  • apps/meteor/app/autotranslate/client/lib/autotranslate.ts
  • apps/meteor/app/cloud/server/index.ts
  • apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts
  • apps/meteor/app/file-upload/ufs/Webdav/server.ts
  • apps/meteor/app/file/server/file.server.ts
  • apps/meteor/app/lib/server/methods/restartServer.ts
  • apps/meteor/app/license/client/index.ts
  • apps/meteor/app/mailer/server/api.ts
  • apps/meteor/app/settings/server/applyMiddlewares.ts
  • apps/meteor/app/settings/server/functions/overrideGenerator.ts
  • apps/meteor/app/smarsh-connector/server/functions/generateEml.ts
  • apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts
  • apps/meteor/app/ui/client/lib/recorderjs/AudioRecorder.ts
  • apps/meteor/app/ui/client/lib/recorderjs/videoRecorder.ts
  • apps/meteor/app/utils/server/functions/getMongoInfo.ts
  • apps/meteor/ee/app/license/server/startup.ts
  • apps/meteor/ee/server/api/licenses.ts
  • apps/meteor/ee/server/apps/storage/AppGridFSSourceStorage.ts
  • apps/meteor/ee/server/hooks/federation/index.ts
  • apps/meteor/ee/server/lib/audit/methods.ts
  • apps/meteor/ee/server/local-services/instance/service.ts
  • apps/meteor/ee/server/startup/presence.ts
  • apps/meteor/server/lib/dataExport/processDataDownloads.ts
  • apps/meteor/server/lib/roles/addUserRoles.ts
  • apps/meteor/server/modules/notifications/notifications.module.ts
  • apps/meteor/server/modules/streamer/streamer.module.ts
  • apps/meteor/server/oauth2-server/model.ts
  • apps/meteor/server/oauth2-server/oauth.ts
  • apps/meteor/server/routes/avatar/utils.ts
  • apps/meteor/server/services/authorization/canAccessRoom.ts
  • apps/meteor/server/services/authorization/service.ts
  • apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts
  • apps/meteor/server/startup/initialData.ts
  • apps/meteor/server/startup/migrations/v312.ts
  • apps/meteor/server/startup/migrations/v319.ts
  • apps/meteor/server/startup/serverRunning.ts
  • apps/meteor/server/ufs/ufs-local.ts
  • apps/meteor/server/ufs/ufs-methods.ts
  • apps/meteor/server/ufs/ufs-server.ts
  • apps/meteor/server/ufs/ufs-store.ts
  • ee/apps/account-service/src/service.ts
  • ee/apps/authorization-service/src/service.ts
  • ee/apps/ddp-streamer/src/Client.ts
  • ee/apps/ddp-streamer/src/DDPStreamer.ts
  • ee/apps/ddp-streamer/src/Streamer.ts
  • ee/apps/ddp-streamer/src/configureServer.ts
  • ee/apps/ddp-streamer/src/service.ts
  • ee/apps/omnichannel-transcript/src/service.ts
  • ee/apps/presence-service/src/service.ts
  • ee/apps/queue-worker/src/service.ts
  • ee/packages/federation-matrix/src/events/ping.ts
  • ee/packages/federation-matrix/src/helpers/createOrUpdateFederatedUser.ts
  • ee/packages/federation-matrix/tests/helper/config.ts
  • ee/packages/federation-matrix/tests/helper/synapse-client.ts
  • ee/packages/license/src/showLicense.ts
  • ee/packages/network-broker/src/index.ts
  • ee/packages/presence/src/Presence.ts
  • ee/packages/presence/src/lib/PresenceReaper.ts
  • packages/api-client/src/index.ts
  • packages/apps-engine/src/client/AppClientManager.ts
  • packages/apps-engine/src/client/AppsEngineUIClient.ts
  • packages/apps-engine/src/server/AppManager.ts
  • packages/apps-engine/src/server/ProxiedApp.ts
  • packages/apps-engine/src/server/accessors/LivechatRead.ts
  • packages/apps-engine/src/server/compiler/AppPackageParser.ts
  • packages/apps-engine/src/server/logging/AppConsole.ts
  • packages/apps-engine/src/server/managers/AppApi.ts
  • packages/apps-engine/src/server/managers/AppListenerManager.ts
  • packages/apps-engine/src/server/managers/AppPermissionManager.ts
  • packages/apps-engine/src/server/managers/AppSchedulerManager.ts
  • packages/apps-engine/src/server/managers/AppSlashCommand.ts
  • packages/apps-engine/src/server/managers/AppVideoConfProvider.ts
  • packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts
  • packages/apps-engine/tests/runner.ts
  • packages/cas-validate/src/validate.ts
  • packages/core-services/src/lib/mongo.ts
  • packages/ddp-client/src/MinimalDDPClient.ts
  • packages/ddp-client/src/types/ClientStream.ts
  • packages/eslint-config/index.js
  • packages/favicon/src/index.ts
  • packages/i18n/src/index.ts
  • packages/livechat/src/lib/connection.ts
  • packages/livechat/src/lib/hooks.ts
  • packages/livechat/src/lib/transcript.ts
  • packages/livechat/src/routes/LeaveMessage/index.tsx
  • packages/livechat/src/routes/SwitchDepartment/index.tsx
  • packages/livechat/src/store/index.tsx
  • packages/livechat/src/widget.ts
  • packages/message-parser/benchmarks/parser.bench.ts
  • packages/models/src/models/BaseRaw.ts
  • packages/models/src/models/Roles.ts
  • packages/models/src/models/Subscriptions.ts
  • packages/models/src/models/Users.ts
  • packages/release-action/src/getMetadata.ts
  • packages/tracing/src/index.ts
  • packages/ui-client/src/components/Modal/GenericModal/withDoNotAskAgain.tsx
  • packages/ui-contexts/src/TranslationContext.ts
  • packages/ui-contexts/src/hooks/useAccountsCustomFields.ts
  • packages/ui-contexts/src/hooks/useAvailableDevices.ts
  • packages/ui-contexts/src/hooks/useDeviceConstraints.ts
  • packages/ui-contexts/src/hooks/useSelectedDevices.ts
  • packages/ui-contexts/src/hooks/useSetInputMediaDevice.ts
  • packages/ui-contexts/src/hooks/useSetOutputMediaDevice.ts
  • packages/ui-voip/src/components/DevicePicker.tsx
  • packages/ui-voip/src/context/MediaCallLogger.ts
  • packages/ui-voip/src/context/MediaCallProvider.tsx
  • packages/ui-voip/src/context/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/useMediaSession.ts
  • packages/ui-voip/src/context/useMediaSessionInstance.ts
  • packages/ui-voip/src/context/useMediaStream.ts
  • packages/ui-voip/src/context/useTonePlayer.ts


if (shouldPreventAnonymousRead || shouldPreventUserRead) {
console.log('shouldPreventAnonymousRead', shouldPreventAnonymousRead);
logger.info('shouldPreventAnonymousRead', shouldPreventAnonymousRead);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking Logger.info signature ==="
rg -n -A5 "info\(" packages/logger/src/index.ts | head -50

echo
echo "=== Checking context around line 838 in ApiClass.ts ==="
sed -n '830,845p' apps/meteor/app/api/server/ApiClass.ts

echo
echo "=== Checking if Logger has multiple overloads or variadic args ==="
rg -B3 -A10 "class Logger" packages/logger/src/index.ts

Repository: RocketChat/Rocket.Chat

Length of output: 1709


Fix invalid logger.info call signature.

Line 838 calls logger.info with two arguments, but Logger.info accepts a single object | string parameter. This violates the type signature and will fail type-checking.

Proposed fix
-							logger.info('shouldPreventAnonymousRead', shouldPreventAnonymousRead);
+							logger.info({ event: 'shouldPreventAnonymousRead', shouldPreventAnonymousRead });
📝 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
logger.info('shouldPreventAnonymousRead', shouldPreventAnonymousRead);
logger.info({ event: 'shouldPreventAnonymousRead', shouldPreventAnonymousRead });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/api/server/ApiClass.ts` at line 838, The logger.info call is
using two positional arguments which breaks the Logger.info(type: object|string)
signature; update the call in ApiClass (the logger.info usage referencing
shouldPreventAnonymousRead) to pass a single value—either a single string
message or an object containing both a descriptive field and the
shouldPreventAnonymousRead value (e.g., { event: 'shouldPreventAnonymousRead',
value: shouldPreventAnonymousRead }) so it matches Logger.info's
single-parameter type.

Comment on lines +30 to 31
logger.info('[OAuth2Server]', 'in grantTypeAllowed (clientId:', token.client.id, ', grantType:', `${scope})`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Logger.info signature in `@rocket.chat/logger` ==="
fd 'index.ts|logger.ts' packages/logger/src --type f | head -5
echo

# Search for info method definition
echo "=== Searching for info method signature ==="
rg -nA 3 'info\s*\(\s*' packages/logger/src --type ts | head -50
echo

echo "=== Multi-arg logger.info calls in oauth2-server/model.ts ==="
rg -nP 'logger\.info\s*\(' apps/meteor/server/oauth2-server/model.ts -A 1 | head -40

Repository: RocketChat/Rocket.Chat

Length of output: 1776


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Full context of lines 132-143 in model.ts ==="
sed -n '132,143p' apps/meteor/server/oauth2-server/model.ts

echo
echo "=== Full context of lines 171-186 in model.ts ==="
sed -n '171,186p' apps/meteor/server/oauth2-server/model.ts

echo
echo "=== Check for overloaded signatures in logger ==="
rg -B5 -A5 'interface.*Logger|class.*Logger' packages/logger/src/index.ts | head -60

Repository: RocketChat/Rocket.Chat

Length of output: 984


logger.info called with unsupported argument arity.

The @rocket.chat/logger API signature is info(msg: object | string): void (single argument only). All multi-arg console-style calls throughout this file must be collapsed into a single string or object payload.

Fix pattern
-			logger.info('[OAuth2Server]', 'in getClient (clientId:', clientId, ', clientSecret:', clientSecret, ')');
+			logger.info({
+				msg: '[OAuth2Server] in getClient',
+				clientId,
+				hasClientSecret: clientSecret != null,
+			});

Applies to lines: 30-31, 43-44, 71-72, 132-143, 171-186

📝 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
logger.info('[OAuth2Server]', 'in grantTypeAllowed (clientId:', token.client.id, ', grantType:', `${scope})`);
}
logger.info({
msg: '[OAuth2Server] in grantTypeAllowed',
clientId: token.client.id,
grantType: scope,
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/server/oauth2-server/model.ts` around lines 30 - 31, The logger
calls use console-style multi-argument signatures but `@rocket.chat/logger` only
accepts a single argument; update every multi-arg logger call in this file
(start with the call inside grantTypeAllowed where logger.info('[OAuth2Server]',
'in grantTypeAllowed (clientId:', token.client.id, ', grantType:', `${scope})`)
and also the other occurrences at the reported ranges) to pass a single string
or a single object payload (e.g., build a template literal or an object with
keys like context, clientId, grantType, token) so each logger.info/logger.warn
invocation has exactly one argument; scan the file for all logger.* calls with
multiple args and replace them with a single formatted string or object while
preserving the same data fields.

}
} catch (e) {
console.log(colors.red('Error processing environment variable INITIAL_USER'), e);
logger.info(colors.red('Error processing environment variable INITIAL_USER'), e);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify Logger.info signature and detect multi-arg usage in this file.

set -euo pipefail

echo "Checking Logger.info signature in packages/logger/src/index.ts"
rg -nP --type=ts '^\s*info\s*\(\s*msg:\s*object\s*\|\s*string\s*\)\s*:\s*void' packages/logger/src/index.ts

echo
echo "Scanning for logger.info calls with 2+ arguments in apps/meteor/server/startup/initialData.ts"
rg -nP --type=ts '\blogger\.info\s*\([^)]*,[^)]*\)' apps/meteor/server/startup/initialData.ts

echo
echo "Expected: signature match above + at least one multi-arg logger.info hit at/near Line 187."

Repository: RocketChat/Rocket.Chat

Length of output: 527


🏁 Script executed:

# Let me also check the Logger interface/class directly to see all method signatures
echo "Checking full Logger interface structure:"
cat packages/logger/src/index.ts | head -100

Repository: RocketChat/Rocket.Chat

Length of output: 1869


🏁 Script executed:

# Check the exact code at line 187 and surrounding context in initialData.ts
echo "Checking context around line 187 in initialData.ts:"
sed -n '180,195p' apps/meteor/server/startup/initialData.ts

Repository: RocketChat/Rocket.Chat

Length of output: 675


Fix invalid Logger.info arity at Line 187.

Logger.info accepts a single object | string argument, but this call passes two. This causes a type error. Additionally, use logger.error() for error conditions in catch blocks instead of info().

🔧 Proposed fix
-			logger.info(colors.red('Error processing environment variable INITIAL_USER'), e);
+			logger.error({
+				message: colors.red('Error processing environment variable INITIAL_USER'),
+				error: e instanceof Error ? { name: e.name, message: e.message, stack: e.stack } : String(e),
+			});
📝 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
logger.info(colors.red('Error processing environment variable INITIAL_USER'), e);
logger.error({
message: colors.red('Error processing environment variable INITIAL_USER'),
error: e instanceof Error ? { name: e.name, message: e.message, stack: e.stack } : String(e),
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/server/startup/initialData.ts` at line 187, The current call
logger.info(colors.red('Error processing environment variable INITIAL_USER'), e)
passes two arguments and uses the wrong level; update the catch to call
logger.error with a single argument that includes both the colored message and
the error details (e.g. format/concatenate the message and e.stack or include an
object like { msg: colors.red('Error processing environment variable
INITIAL_USER'), error: e }) so the single-argument signature is respected;
locate the catch handling around INITIAL_USER processing and replace
logger.info(...) with the single-argument logger.error(...) call referencing
logger and INITIAL_USER.

res.end('ok');
} catch (err) {
console.error('Service not healthy', err);
logger.error('Service not healthy', err);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 1) Find the Logger implementation ==="
fd -t f "index.ts" packages/logger/src/ 2>/dev/null | head -5

echo
echo "=== 2) Check Logger.error signature ==="
if [ -f "packages/logger/src/index.ts" ]; then
  cat -n packages/logger/src/index.ts | head -100
fi

echo
echo "=== 3) Check the file and line in question ==="
if [ -f "ee/apps/omnichannel-transcript/src/service.ts" ]; then
  wc -l ee/apps/omnichannel-transcript/src/service.ts
  echo "Lines 30-45:"
  sed -n '30,45p' ee/apps/omnichannel-transcript/src/service.ts | cat -n
fi

Repository: RocketChat/Rocket.Chat

Length of output: 3045


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 4) Search for logger.error usage patterns in codebase ==="
echo "Pattern 1: logger.error with object argument"
rg -n 'logger\.error\(\s*\{' ee/apps/omnichannel-transcript/src/ -A 2 | head -20

echo
echo "Pattern 2: logger.error with string + additional args"
rg -n 'logger\.error\([^{]' ee/apps/omnichannel-transcript/src/ -A 1 | head -30

Repository: RocketChat/Rocket.Chat

Length of output: 172


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 5) Check actual Logger class definition in packages/logger ==="
find packages/logger/src -name "*.ts" -type f | xargs wc -l | sort -n

Repository: RocketChat/Rocket.Chat

Length of output: 250


Fix invalid Logger.error call signature (extra argument).

At line 36, logger.error('Service not healthy', err) passes two arguments, but Logger.error accepts a single object | string parameter. This is a TypeScript correctness error.

Proposed fix
-				logger.error('Service not healthy', err);
+				logger.error({ msg: 'Service not healthy', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/omnichannel-transcript/src/service.ts` at line 36, The logger.error
call uses an invalid two-argument signature; update the call in service.ts where
logger.error('Service not healthy', err) is used to pass a single parameter
(either a single string with the error interpolated or a single object
containing both message and error), e.g., construct one object { message:
'Service not healthy', error: err } or a single formatted string and pass that
to logger.error so the call matches Logger.error(object | string).

res.end('ok');
} catch (err) {
console.error('Service not healthy', err);
logger.error('Service not healthy', err);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Finding Logger.error signature ==="
find . -name "index.ts" -path "*/packages/logger/*" -type f | head -5

Repository: RocketChat/Rocket.Chat

Length of output: 135


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking Logger.error definition ==="
rg -n "error" packages/logger/src/index.ts -A 3 -B 1 | head -50

Repository: RocketChat/Rocket.Chat

Length of output: 230


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking queue-worker logger.error at line 34 ==="
sed -n '30,40p' ee/apps/queue-worker/src/service.ts | cat -n

Repository: RocketChat/Rocket.Chat

Length of output: 395


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking logger type in queue-worker/service.ts ==="
rg -n "logger\s*[:=]" ee/apps/queue-worker/src/service.ts | head -10

Repository: RocketChat/Rocket.Chat

Length of output: 165


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Logger class implementation ==="
cat -n packages/logger/src/index.ts | head -100

Repository: RocketChat/Rocket.Chat

Length of output: 2500


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Examples of logger.error with object arguments ==="
rg -n "logger\.error\(\{" --type ts | head -20

Repository: RocketChat/Rocket.Chat

Length of output: 2563


logger.error() receives invalid argument shape — expects single object | string, receives two arguments.

At line 34, logger.error('Service not healthy', err) violates the signature. The Logger.error method accepts a single parameter (object or string), not two separate arguments. Pass an object with both msg and err properties instead.

Fix
-				logger.error('Service not healthy', err);
+				logger.error({ msg: 'Service not healthy', err });
📝 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
logger.error('Service not healthy', err);
logger.error({ msg: 'Service not healthy', err });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/apps/queue-worker/src/service.ts` at line 34, The logger.error call
currently passes two arguments; change it to pass a single argument (an object
or string) by replacing the two-argument call to logger.error with a single
object that contains both a message field (e.g., "Service not healthy") and the
caught error (err) so the call becomes logger.error with one object argument;
locate the occurrence of logger.error('Service not healthy', err) in service.ts
and update the call signature and any typing to match Logger.error(object |
string).

Comment on lines +25 to +30
logger.info('---- License enabled ----');
logger.info(' url ->', JSON.stringify(serverUrls));
logger.info(' periods ->', JSON.stringify(validPeriods));
logger.info(' limits ->', JSON.stringify(limits));
logger.info(' modules ->', modules.join(', '));
logger.info('-------------------------');
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Logger.info only accepts a single argument; data will be silently discarded.

The Logger.info method signature is info(msg: object | string): void, accepting only one argument. The current calls pass two arguments (e.g., logger.info('url ->', JSON.stringify(serverUrls))), so only the label string is logged while the actual license data is ignored.

Proposed fix using template literals
-	logger.info('---- License enabled ----');
-	logger.info('              url ->', JSON.stringify(serverUrls));
-	logger.info('          periods ->', JSON.stringify(validPeriods));
-	logger.info('           limits ->', JSON.stringify(limits));
-	logger.info('          modules ->', modules.join(', '));
-	logger.info('-------------------------');
+	logger.info('---- License enabled ----');
+	logger.info(`              url -> ${JSON.stringify(serverUrls)}`);
+	logger.info(`          periods -> ${JSON.stringify(validPeriods)}`);
+	logger.info(`           limits -> ${JSON.stringify(limits)}`);
+	logger.info(`          modules -> ${modules.join(', ')}`);
+	logger.info('-------------------------');
📝 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
logger.info('---- License enabled ----');
logger.info(' url ->', JSON.stringify(serverUrls));
logger.info(' periods ->', JSON.stringify(validPeriods));
logger.info(' limits ->', JSON.stringify(limits));
logger.info(' modules ->', modules.join(', '));
logger.info('-------------------------');
logger.info('---- License enabled ----');
logger.info(` url -> ${JSON.stringify(serverUrls)}`);
logger.info(` periods -> ${JSON.stringify(validPeriods)}`);
logger.info(` limits -> ${JSON.stringify(limits)}`);
logger.info(` modules -> ${modules.join(', ')}`);
logger.info('-------------------------');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ee/packages/license/src/showLicense.ts` around lines 25 - 30, The logger
calls pass two arguments but Logger.info accepts a single msg, so the data
(serverUrls, validPeriods, limits, modules) is dropped; update each call to
build a single string or object (e.g., use template literals or JSON objects)
and pass that single value to logger.info — change calls referencing
logger.info('url ->', JSON.stringify(serverUrls)), logger.info('periods ->',
JSON.stringify(validPeriods)), logger.info('limits ->', JSON.stringify(limits)),
and logger.info('modules ->', modules.join(', ')) to pass one combined message
that includes the label and the serialized data in the same argument.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant