Skip to content

Comments

Fix outlook processing#917

Merged
elie222 merged 1 commit intomainfrom
fix/outlook-webhook
Nov 5, 2025
Merged

Fix outlook processing#917
elie222 merged 1 commit intomainfrom
fix/outlook-webhook

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Nov 5, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of Outlook folder caching to enhance email synchronization performance.
  • Chores

    • Version bumped to v2.17.43.

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
inbox-zero Building Building Preview Nov 5, 2025 10:36pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

The PR refactors folder ID caching in the Outlook client utilities from a module-level global cache to a per-client caching mechanism by adding getter/setter methods to OutlookClient and updating the message module to use this new API instead of maintaining its own cache.

Changes

Cohort / File(s) Summary
OutlookClient cache accessor/mutator implementation
apps/web/utils/outlook/client.ts
Added folderIdCache private field (initially null) with corresponding getFolderIdCache() and setFolderIdCache() public methods to store and retrieve folder ID mappings per client instance
Message module cache migration
apps/web/utils/outlook/message.ts
Migrated from module-level folderIdCache to per-client caching via client.getFolderIdCache() and client.setFolderIdCache() in getFolderIds() function; renamed accumulation variable from folderIdCache to userFolderIds for clarity
Version bump
version.txt
Updated version from v2.17.42 to v2.17.43

Sequence Diagram

sequenceDiagram
    participant Caller
    participant getMessage as message.getFolderIds()
    participant Client as OutlookClient
    participant Graph as Microsoft Graph API

    Caller->>getMessage: Call getFolderIds()
    getMessage->>Client: getFolderIdCache()
    
    alt Cache exists
        Client-->>getMessage: Return cached userFolderIds
        getMessage-->>Caller: Return cached mapping
    else Cache miss
        getMessage->>Graph: Fetch well-known folders
        Graph-->>getMessage: Folder list
        getMessage->>getMessage: Build userFolderIds map
        getMessage->>Client: setFolderIdCache(userFolderIds)
        Client->>Client: Store in folderIdCache
        getMessage-->>Caller: Return new mapping
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Attention areas:
    • Verify the caching logic in getFolderIds() correctly checks for cached values before fetching
    • Confirm that the variable renaming from folderIdCache to userFolderIds is consistent and doesn't affect other logic
    • Ensure null-safety of the cache operations (checking for null before returning/using cached values)
    • Validate that per-client caching doesn't introduce unintended cache isolation or sharing issues depending on client lifecycle

Possibly related PRs

  • Fix outlook webhook #836 — Modifies getFolderIds() implementation in the same file (removes logging); direct overlap with this PR's caching refactor
  • Don't load threads for outlook draft #907 — Updates thread.ts to call getFolderIds() for message handling; uses the cached folder ID retrieval that this PR refactors
  • Fix outlook error #839 — Modifies apps/web/utils/outlook/message.ts to use folder IDs and adds queryMessagesWithFilters; touches the same caching and folder-ID retrieval logic

Suggested reviewers

  • mosesjames7271-svg

Poem

🐰 A Cache Refactored

From global shelves to client's keep,
The folder IDs now nest,
Per-instance caches, tucked so deep—
No sharing, just the best!
Setter, getter, clean and neat,
v2.17.43's sweet retreat! 📦

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix outlook processing' is vague and generic, lacking specificity about what aspect of Outlook processing is being fixed or what the actual changes address. Consider a more specific title such as 'Migrate folder ID cache from module-level to per-client storage' to better communicate the primary technical change.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/outlook-webhook

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d017a4a and 43645c4.

📒 Files selected for processing (3)
  • apps/web/utils/outlook/client.ts (2 hunks)
  • apps/web/utils/outlook/message.ts (2 hunks)
  • version.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
!{.cursor/rules/*.mdc}

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

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • version.txt
  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
!pages/_document.{js,jsx,ts,tsx}

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

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • version.txt
  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
**/*.{ts,tsx}

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

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
apps/web/utils/**

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
apps/web/utils/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
**/*.{js,jsx,ts,tsx}

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

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/utils/outlook/client.ts
  • apps/web/utils/outlook/message.ts
🧠 Learnings (1)
📚 Learning: 2025-07-18T15:05:34.899Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-07-18T15:05:34.899Z
Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')

Applied to files:

  • apps/web/utils/outlook/message.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Jit Security
  • GitHub Check: test
🔇 Additional comments (4)
version.txt (1)

1-1: LGTM! Standard version bump.

The version increment accompanies the folder ID caching refactor.

apps/web/utils/outlook/client.ts (2)

22-22: Good encapsulation with per-client cache.

The private cache field properly encapsulates folder ID storage at the client instance level, which is safer than module-level caching for multi-user scenarios.


49-55: Clean accessor methods for cache management.

The getter and setter provide a type-safe interface for managing the folder ID cache. Implementation is straightforward with no unnecessary complexity.

apps/web/utils/outlook/message.ts (1)

78-113: Excellent refactoring to per-client caching.

The migration from module-level to per-client caching is well-executed:

  • Properly uses the new client.getFolderIdCache() and client.setFolderIdCache() API
  • Eliminates global mutable state
  • Safer for scenarios with multiple client instances
  • Variable rename to userFolderIds improves clarity

Based on learnings: This keeps provider-specific implementation details properly isolated within the Outlook utilities.


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.

No issues found across 3 files

@elie222 elie222 merged commit a3ed97f into main Nov 5, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant