fix: tests failing in getOutlookEvents.spec.ts#3239
fix: tests failing in getOutlookEvents.spec.ts#3239SantamRC wants to merge 4 commits intoRocketChat:masterfrom
getOutlookEvents.spec.ts#3239Conversation
WalkthroughAdds a helper Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/outlookCalendar/getOutlookEvents.ts (1)
175-194:⚠️ Potential issue | 🟡 MinorNormalize the raw URL once before branching on these edge cases.
Line 179 checks the untrimmed
serverUrl, while Line 190 trims before fallback construction. That means inputs like' mail.example.com:443/ews 'now rethrowInvalid protocolinstead of taking the fallback that would succeed after trimming. The empty-hostname remap also only recognizeshttps://, so barehttp://still falls through to the composite error even though HTTP is supported.Suggested fix
+ const trimmedServerUrl = serverUrl.trim(); const errorMessage = error instanceof Error ? error.message : String(error); // Re-throw validation errors without attempting fallback, except for cases // where the URL looks like it's missing a protocol (e.g., "domain.com:443") - if (errorMessage.includes('Invalid protocol') && !serverUrl.match(/^[a-z0-9.-]+:\d+/i)) { + if ( + errorMessage.includes('Invalid protocol') && + !trimmedServerUrl.match(/^[a-z0-9.-]+:\d+/i) + ) { throw error; } // Try to fix common URL issues - let fallbackUrl = serverUrl.trim(); + let fallbackUrl = trimmedServerUrl; … - if (fallbackErrorMsg.includes('Invalid URL') && fallbackUrl === 'https://') { + if ( + fallbackErrorMsg.includes('Invalid URL') && + /^https?:\/\/$/.test(fallbackUrl) + ) { throw new Error('URL must have a valid hostname'); }Also applies to: 249-252
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/outlookCalendar/getOutlookEvents.ts` around lines 175 - 194, Trim and normalize serverUrl once at the top of the URL-error handling branch (e.g., replace usages of serverUrl with a new normalizedServerUrl = serverUrl.trim()) and use normalizedServerUrl for the Invalid protocol check (the regex /^[a-z0-9.-]+:\d+/i) and all subsequent fallback logic; ensure the "add protocol" check and empty-hostname remap use the normalized value and accept both http and https (use /^https?:\/\// when detecting existing protocol and allow remapping for http as well). Apply the same normalization change to the later fallback block referenced around the empty-hostname remap so both blocks use the same normalizedServerUrl and consistent protocol handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/outlookCalendar/getOutlookEvents.ts`:
- Around line 219-228: The code inconsistently preserves default ports: the main
branch uses url.toString() (which drops default ports) while the fallback uses
serverUrl.match(/:(\d+)/) to reconstruct a port, which can mis-detect ports
outside the authority; update the fallback to read the port from the parsed URL
object (use url.port or url.hostname/url.host) instead of regexing serverUrl,
and apply the same port-preservation logic used in the fallback to the primary
path (or decide to always omit default ports). Concretely, change the port
extraction to use url.port and only append `${url.hostname}:${port}` when
url.port is present and not a non-default port, and ensure the same finalUrl
construction is used in both branches (variables: url, serverUrl, finalUrl).
---
Outside diff comments:
In `@src/outlookCalendar/getOutlookEvents.ts`:
- Around line 175-194: Trim and normalize serverUrl once at the top of the
URL-error handling branch (e.g., replace usages of serverUrl with a new
normalizedServerUrl = serverUrl.trim()) and use normalizedServerUrl for the
Invalid protocol check (the regex /^[a-z0-9.-]+:\d+/i) and all subsequent
fallback logic; ensure the "add protocol" check and empty-hostname remap use the
normalized value and accept both http and https (use /^https?:\/\// when
detecting existing protocol and allow remapping for http as well). Apply the
same normalization change to the later fallback block referenced around the
empty-hostname remap so both blocks use the same normalizedServerUrl and
consistent protocol handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 065d27b7-04bf-46a5-8169-ca843e1daa86
📒 Files selected for processing (1)
src/outlookCalendar/getOutlookEvents.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode enabled in TypeScript configuration
Use React functional components with hooks instead of class components
Follow FSA (Flux Standard Action) pattern for Redux actions
Use camelCase for file names and PascalCase for component file names
All code must pass ESLint and TypeScript checks
Write self-documenting code with clear naming; avoid unnecessary comments except for complex business logic or non-obvious decisions
Use Fuselage components from@rocket.chat/fuselagefor all UI work and only create custom components when Fuselage doesn't provide what's needed
CheckTheme.d.tsfor valid color tokens when using Fuselage components
Use defensive coding with optional chaining and fallbacks for Linux-only APIs (process.getuid(), process.getgid(), process.geteuid(), process.getegid()) to ensure cross-platform compatibility across Windows, macOS, and Linux
Files:
src/outlookCalendar/getOutlookEvents.ts
src/outlookCalendar/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/outlookCalendar/AGENTS.md)
src/outlookCalendar/**/*.{ts,tsx}: UsecreateClassifiedError()fromerrorClassification.tsfor user-facing errors to provide error categorization, user-friendly messages, and structured error context
Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Files:
src/outlookCalendar/getOutlookEvents.ts
🧠 Learnings (3)
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Use `createClassifiedError()` from `errorClassification.ts` for user-facing errors to provide error categorization, user-friendly messages, and structured error context
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*(!preload).ts?(x) : Always use the centralized logger from `logger.ts` (outlookLog, outlookDebug, outlookError, outlookWarn, outlookEventDetail) instead of console.log() for Outlook Calendar module logging
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
🪛 ESLint
src/outlookCalendar/getOutlookEvents.ts
[error] 179-179: Replace errorMessage.includes('Invalid·protocol')·&&·!serverUrl.match(/^[a-z0-9.-]+:\d+/i) with ⏎······errorMessage.includes('Invalid·protocol')·&&⏎······!serverUrl.match(/^[a-z0-9.-]+:\d+/i)⏎····
(prettier/prettier)
[error] 224-224: Insert ⏎··········
(prettier/prettier)
[error] 225-225: Replace ··(url.protocol·===·'http:'·&&·port·===·'80') with (url.protocol·===·'http:'·&&·port·===·'80')⏎········
(prettier/prettier)
[error] 241-241: Replace ·fallbackError·instanceof·Error·?·fallbackError.message with ⏎········fallbackError·instanceof·Error⏎··········?·fallbackError.message⏎·········
(prettier/prettier)
[error] 244-244: Insert ⏎········
(prettier/prettier)
[error] 245-245: Replace ··fallbackErrorMsg.includes('Invalid·protocol') with fallbackErrorMsg.includes('Invalid·protocol')⏎······
(prettier/prettier)
[error] 250-250: Replace fallbackErrorMsg.includes('Invalid·URL')·&&·fallbackUrl·===·'https://' with ⏎········fallbackErrorMsg.includes('Invalid·URL')·&&⏎········fallbackUrl·===·'https://'⏎······
(prettier/prettier)
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/outlookCalendar/getOutlookEvents.ts`:
- Around line 267-269: The branch that treats empty-host errors only for
'https://' must also cover 'http://'; update the conditional that checks
fallbackErrorMsg and fallbackUrl (used in getOutlookEvents flow) to treat both
protocols the same (e.g., change the check from fallbackUrl === 'https://' to
include fallbackUrl === 'http://' or normalize by stripping protocol and
checking for an empty hostname) and throw the same Error('URL must have a valid
hostname') so http and https empty-host cases are handled consistently.
- Around line 204-208: The current heuristic in getOutlookEvents that checks
serverUrl.match(/^[a-z0-9.-]+:\d+/i) treats scheme:port (e.g., "ftp:21") as
host:port; change it to only match real hostnames or IPv4 addresses with ports
(for example require a dot in the hostname or match IPv4), e.g. replace the
regex with one that matches either an IPv4 address or a hostname containing a
dot before the colon (e.g.,
/^(?:\d{1,3}(?:\.\d{1,3}){3}|[a-z0-9-]+\.[a-z0-9.-]+):\d+/i) so that legitimate
schemes like "ftp:21" will not bypass the Invalid protocol re-throw in the error
handling around the Invalid protocol check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a7225a0b-2723-4a5f-93ef-ea11268a3e74
📒 Files selected for processing (1)
src/outlookCalendar/getOutlookEvents.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode enabled in TypeScript configuration
Use React functional components with hooks instead of class components
Follow FSA (Flux Standard Action) pattern for Redux actions
Use camelCase for file names and PascalCase for component file names
All code must pass ESLint and TypeScript checks
Write self-documenting code with clear naming; avoid unnecessary comments except for complex business logic or non-obvious decisions
Use Fuselage components from@rocket.chat/fuselagefor all UI work and only create custom components when Fuselage doesn't provide what's needed
CheckTheme.d.tsfor valid color tokens when using Fuselage components
Use defensive coding with optional chaining and fallbacks for Linux-only APIs (process.getuid(), process.getgid(), process.geteuid(), process.getegid()) to ensure cross-platform compatibility across Windows, macOS, and Linux
Files:
src/outlookCalendar/getOutlookEvents.ts
src/outlookCalendar/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/outlookCalendar/AGENTS.md)
src/outlookCalendar/**/*.{ts,tsx}: UsecreateClassifiedError()fromerrorClassification.tsfor user-facing errors to provide error categorization, user-friendly messages, and structured error context
Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Files:
src/outlookCalendar/getOutlookEvents.ts
🧠 Learnings (3)
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Use `createClassifiedError()` from `errorClassification.ts` for user-facing errors to provide error categorization, user-friendly messages, and structured error context
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*(!preload).ts?(x) : Always use the centralized logger from `logger.ts` (outlookLog, outlookDebug, outlookError, outlookWarn, outlookEventDetail) instead of console.log() for Outlook Calendar module logging
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
🪛 ESLint
src/outlookCalendar/getOutlookEvents.ts
[error] 122-122: Insert ⏎······
(prettier/prettier)
[error] 123-123: Replace ··(url.protocol·===·'http:'·&&·explicitPort·===·'80') with (url.protocol·===·'http:'·&&·explicitPort·===·'80')⏎····
(prettier/prettier)
[error] 206-206: Replace errorMessage.includes('Invalid·protocol')·&&·!serverUrl.match(/^[a-z0-9.-]+:\d+/i) with ⏎······errorMessage.includes('Invalid·protocol')·&&⏎······!serverUrl.match(/^[a-z0-9.-]+:\d+/i)⏎····
(prettier/prettier)
[error] 259-259: Replace ·fallbackError·instanceof·Error·?·fallbackError.message with ⏎········fallbackError·instanceof·Error⏎··········?·fallbackError.message⏎·········
(prettier/prettier)
[error] 262-262: Insert ⏎········
(prettier/prettier)
[error] 263-263: Replace ··fallbackErrorMsg.includes('Invalid·protocol') with fallbackErrorMsg.includes('Invalid·protocol')⏎······
(prettier/prettier)
[error] 268-268: Replace fallbackErrorMsg.includes('Invalid·URL')·&&·fallbackUrl·===·'https://' with ⏎········fallbackErrorMsg.includes('Invalid·URL')·&&⏎········fallbackUrl·===·'https://'⏎······
(prettier/prettier)
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/outlookCalendar/getOutlookEvents.ts`:
- Around line 122-123: The multiline boolean condition in getOutlookEvents using
(url.protocol === 'https:' && explicitPort === '443') || (url.protocol ===
'http:' && explicitPort === '80') is triggering Prettier/ESLint failures;
reformat it to satisfy Prettier (e.g., collapse to a single line or follow the
project’s preferred wrapping) and apply the same formatting fixes to the other
offending condition blocks in this file (the other occurrences that check
url.protocol and explicitPort). Locate the checks in getOutlookEvents where url
and explicitPort are compared and adjust their formatting to match the project's
Prettier rules so the file passes linting.
- Around line 204-209: The current check in getOutlookEvents.ts rethrows
"Invalid protocol" unless serverUrl matches only IPv4 or dotted hostnames;
update the regex used in the if (errorMessage.includes('Invalid protocol') &&
!serverUrl.match(...)) to also accept single-label hostnames (e.g., "mail" or
"localhost") with ports by changing the hostname part from
[a-z0-9-]+\.[a-z0-9.-]+ to allow an optional dot — e.g.
[a-z0-9-]+(?:\.[a-z0-9.-]+)? — so serverUrl like "mail:443/ews" or
"localhost:443/ews" will not be rethrown and can reach the fallback
normalization branch.
- Around line 118-124: The current port-extraction regex (used in portMatch =
originalUrl.match(...)) only catches non-bracketed hosts so URLs like
https://[2001:db8::1]:443/... lose the explicit port; update the regex to also
match bracketed IPv6 hosts (e.g. something like
/(?:\/\/|^)(?:\[[^\]]+\]|[^/:]+):(\d+)/) so explicitPort captures ports after
[ipv6] as well, keep the existing logic that checks url.protocol and
explicitPort and return baseUrl.replace(url.host,
`${url.hostname}:${explicitPort}`) when restoring default ports.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ea24792-f948-4b26-99fa-827ae0dd7c5c
📒 Files selected for processing (1)
src/outlookCalendar/getOutlookEvents.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode enabled in TypeScript configuration
Use React functional components with hooks instead of class components
Follow FSA (Flux Standard Action) pattern for Redux actions
Use camelCase for file names and PascalCase for component file names
All code must pass ESLint and TypeScript checks
Write self-documenting code with clear naming; avoid unnecessary comments except for complex business logic or non-obvious decisions
Use Fuselage components from@rocket.chat/fuselagefor all UI work and only create custom components when Fuselage doesn't provide what's needed
CheckTheme.d.tsfor valid color tokens when using Fuselage components
Use defensive coding with optional chaining and fallbacks for Linux-only APIs (process.getuid(), process.getgid(), process.geteuid(), process.getegid()) to ensure cross-platform compatibility across Windows, macOS, and Linux
Files:
src/outlookCalendar/getOutlookEvents.ts
src/outlookCalendar/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/outlookCalendar/AGENTS.md)
src/outlookCalendar/**/*.{ts,tsx}: UsecreateClassifiedError()fromerrorClassification.tsfor user-facing errors to provide error categorization, user-friendly messages, and structured error context
Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Files:
src/outlookCalendar/getOutlookEvents.ts
🧠 Learnings (3)
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Use `createClassifiedError()` from `errorClassification.ts` for user-facing errors to provide error categorization, user-friendly messages, and structured error context
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*(!preload).ts?(x) : Always use the centralized logger from `logger.ts` (outlookLog, outlookDebug, outlookError, outlookWarn, outlookEventDetail) instead of console.log() for Outlook Calendar module logging
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
🪛 ESLint
src/outlookCalendar/getOutlookEvents.ts
[error] 122-122: Insert ⏎······
(prettier/prettier)
[error] 123-123: Replace ··(url.protocol·===·'http:'·&&·explicitPort·===·'80') with (url.protocol·===·'http:'·&&·explicitPort·===·'80')⏎····
(prettier/prettier)
[error] 207-207: Replace errorMessage.includes('Invalid·protocol')·&&·!serverUrl.match(/^(?:\d{1,3}(?:\.\d{1,3}){3}|[a-z0-9-]+\.[a-z0-9.-]+):\d+/i) with ⏎······errorMessage.includes('Invalid·protocol')·&&⏎······!serverUrl.match(⏎········/^(?:\d{1,3}(?:\.\d{1,3}){3}|[a-z0-9-]+\.[a-z0-9.-]+):\d+/i⏎······)⏎····
(prettier/prettier)
[error] 260-260: Replace ·fallbackError·instanceof·Error·?·fallbackError.message with ⏎········fallbackError·instanceof·Error⏎··········?·fallbackError.message⏎·········
(prettier/prettier)
[error] 263-263: Insert ⏎········
(prettier/prettier)
[error] 264-264: Replace ··fallbackErrorMsg.includes('Invalid·protocol') with fallbackErrorMsg.includes('Invalid·protocol')⏎······
(prettier/prettier)
[error] 269-269: Replace fallbackErrorMsg.includes('Invalid·URL')·&&·fallbackUrl.match(/^https?:\/\/$/) with ⏎········fallbackErrorMsg.includes('Invalid·URL')·&&⏎········fallbackUrl.match(/^https?:\/\/$/)⏎······
(prettier/prettier)
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/outlookCalendar/getOutlookEvents.ts (1)
289-292: Inconsistent indentation in error message template.The multiline template literal includes leading spaces from the source code indentation, which will appear in the error message output. This results in "Original error:" and subsequent lines being indented with extra spaces.
♻️ Suggested fix
- const fallbackErrorMessage = `Failed to create valid Exchange URL from "${serverUrl}". - Original error: ${errorMessage}. - Fallback error: ${fallbackErrorMsg}. + const fallbackErrorMessage = `Failed to create valid Exchange URL from "${serverUrl}". ` + + `Original error: ${errorMessage}. ` + + `Fallback error: ${fallbackErrorMsg}. ` + Please ensure the URL includes a valid protocol (http:// or https://) and hostname.`;Or use a single line if preferred for error messages.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/outlookCalendar/getOutlookEvents.ts` around lines 289 - 292, The multiline template assigned to fallbackErrorMessage in getOutlookEvents.ts contains source-code indentation that will be preserved in the error string; remove the leading spaces by collapsing it into a single-line message or by trimming the template (e.g., build the string without leading spaces or call .trim() on the template) and ensure it still includes serverUrl, errorMessage, and fallbackErrorMsg for context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/outlookCalendar/getOutlookEvents.ts`:
- Around line 289-292: The multiline template assigned to fallbackErrorMessage
in getOutlookEvents.ts contains source-code indentation that will be preserved
in the error string; remove the leading spaces by collapsing it into a
single-line message or by trimming the template (e.g., build the string without
leading spaces or call .trim() on the template) and ensure it still includes
serverUrl, errorMessage, and fallbackErrorMsg for context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 928aacab-dbca-41f3-838b-699a885309ff
📒 Files selected for processing (1)
src/outlookCalendar/getOutlookEvents.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode enabled in TypeScript configuration
Use React functional components with hooks instead of class components
Follow FSA (Flux Standard Action) pattern for Redux actions
Use camelCase for file names and PascalCase for component file names
All code must pass ESLint and TypeScript checks
Write self-documenting code with clear naming; avoid unnecessary comments except for complex business logic or non-obvious decisions
Use Fuselage components from@rocket.chat/fuselagefor all UI work and only create custom components when Fuselage doesn't provide what's needed
CheckTheme.d.tsfor valid color tokens when using Fuselage components
Use defensive coding with optional chaining and fallbacks for Linux-only APIs (process.getuid(), process.getgid(), process.geteuid(), process.getegid()) to ensure cross-platform compatibility across Windows, macOS, and Linux
Files:
src/outlookCalendar/getOutlookEvents.ts
src/outlookCalendar/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/outlookCalendar/AGENTS.md)
src/outlookCalendar/**/*.{ts,tsx}: UsecreateClassifiedError()fromerrorClassification.tsfor user-facing errors to provide error categorization, user-friendly messages, and structured error context
Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Files:
src/outlookCalendar/getOutlookEvents.ts
🧠 Learnings (3)
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Use `createClassifiedError()` from `errorClassification.ts` for user-facing errors to provide error categorization, user-friendly messages, and structured error context
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*.{ts,tsx} : Always use outlookError() for errors as it logs regardless of verbose mode settings, ensuring errors are always visible to users
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
📚 Learning: 2026-03-06T19:31:11.422Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.Electron PR: 0
File: src/outlookCalendar/AGENTS.md:0-0
Timestamp: 2026-03-06T19:31:11.422Z
Learning: Applies to src/outlookCalendar/**/*(!preload).ts?(x) : Always use the centralized logger from `logger.ts` (outlookLog, outlookDebug, outlookError, outlookWarn, outlookEventDetail) instead of console.log() for Outlook Calendar module logging
Applied to files:
src/outlookCalendar/getOutlookEvents.ts
🔇 Additional comments (6)
src/outlookCalendar/getOutlookEvents.ts (6)
104-132: Well-designed helper for preserving explicit default ports.The
buildFinalUrlhelper correctly addresses the URL serialization asymmetry. The regex on line 119 properly handles:
- Regular hostnames (
mail.example.com:443)- IPv6 addresses in brackets (
[2001:db8::1]:443)- URLs without protocol (
domain.com:443)The logic cleanly separates the check for non-default ports (already preserved by
toString()) from explicit default ports that need restoration.
189-189: LGTM!Consistent use of
buildFinalUrlin the main path aligns with the fallback path behavior.
205-217: LGTM!The updated regex pattern correctly allows single-label hostnames (e.g.,
localhost:443,mail:443) to proceed to the fallback path rather than being incorrectly rejected as invalid protocols.
245-250: LGTM!Protocol validation in the fallback path mirrors the main path, ensuring consistent behavior regardless of which code path handles the URL.
255-255: LGTM!Correctly passes the original
serverUrltobuildFinalUrlto preserve port information from the user's input.
282-287: LGTM!The regex
/^https?:\/\/$/correctly handles bothhttp://andhttps://empty hostname cases, addressing the prior inconsistency between protocols.
When running tests in
getOutlookEvents.spec.ts, 3 tests were failing.Logs,
Changes:
domain.com:443)Summary by CodeRabbit