Skip to content

Fix labelling and logger#900

Merged
elie222 merged 2 commits intomainfrom
fix/logger
Nov 3, 2025
Merged

Fix labelling and logger#900
elie222 merged 2 commits intomainfrom
fix/logger

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Nov 3, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved label application logic and error handling for thread status operations.
    • Enhanced logging for better diagnostics during label operations.
  • Chores

    • Version bump to v2.17.30.

@vercel
Copy link

vercel bot commented Nov 3, 2025

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

Project Deployment Preview Updated (UTC)
inbox-zero Ready Ready Preview Nov 3, 2025 7:14pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

This PR adds serialization support to email provider classes by introducing a toJSON() method to the EmailProvider interface and its implementations (GmailProvider, OutlookProvider, and mock). Additionally, it refines label-fetching logic in label-helpers.ts with stricter error checking and updates logging to use provider.name. Version bumped to v2.17.30.

Changes

Cohort / File(s) Summary
Email Provider Serialization
apps/web/utils/email/types.ts, apps/web/utils/email/google.ts, apps/web/utils/email/microsoft.ts, apps/web/utils/__mocks__/email-provider.ts
Added toJSON() method to EmailProvider interface and all implementations (GmailProvider, OutlookProvider, mock). Each returns an object with name and type fields for provider metadata serialization.
Label Helpers Refactoring
apps/web/utils/reply-tracker/label-helpers.ts
Updated logging to use provider.name instead of full provider object. Simplified label fetch/create logic to require only labelId. Refined error handling to check strictly for missing labelId with enhanced logging including systemType and labelName.
Version Bump
version.txt
Updated version from v2.17.29 to v2.17.30.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • label-helpers.ts: Review the logic changes to label fetching/creation, error handling refactoring, and the impact of stricter checks on downstream behavior
  • Provider serialization consistency: Verify that toJSON() implementations align across mock, interface, and concrete provider classes

Possibly related PRs

Suggested reviewers

  • mosesjames7271-svg

Poem

🐰 A hop and a JSON delight,
Providers now serialize just right,
Labels fetch cleaner, errors align,
Provider names logged so divine,
v2.17.30 shines bright!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix labelling and logger' is somewhat vague and generic. While it hints at fixing labeling and logging functionality, it doesn't clearly convey the specific nature of the changes (adding toJSON methods to email providers and adjusting label helpers logic). Consider a more specific title that reflects the main changes, such as 'Add toJSON serialization to email providers and refine label-helpers logic' or similar descriptive phrasing.
✅ 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/logger

📜 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 d749bea and a058db3.

📒 Files selected for processing (6)
  • apps/web/utils/__mocks__/email-provider.ts (1 hunks)
  • apps/web/utils/email/google.ts (1 hunks)
  • apps/web/utils/email/microsoft.ts (1 hunks)
  • apps/web/utils/email/types.ts (1 hunks)
  • apps/web/utils/reply-tracker/label-helpers.ts (4 hunks)
  • version.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.ts
!{.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:

  • apps/web/utils/email/types.ts
  • version.txt
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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/email/types.ts
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.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:

  • apps/web/utils/email/types.ts
  • version.txt
  • apps/web/utils/__mocks__/email-provider.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/reply-tracker/label-helpers.ts
  • apps/web/utils/email/google.ts
🧠 Learnings (4)
📚 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/email/types.ts
  • apps/web/utils/email/microsoft.ts
  • apps/web/utils/email/google.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Use provided helpers for mocks: import `{ getEmail, getEmailAccount, getRule }` from `@/__tests__/helpers`

Applied to files:

  • apps/web/utils/__mocks__/email-provider.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers

Applied to files:

  • apps/web/utils/__mocks__/email-provider.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Use descriptive scoped loggers for each feature

Applied to files:

  • apps/web/utils/reply-tracker/label-helpers.ts
🧬 Code graph analysis (1)
apps/web/utils/reply-tracker/label-helpers.ts (3)
apps/web/app/api/outlook/webhook/logger.ts (1)
  • logger (3-3)
apps/web/utils/rule/consts.ts (1)
  • getRuleLabel (122-124)
apps/web/utils/label.server.ts (1)
  • labelMessageAndSync (13-72)
⏰ 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). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
🔇 Additional comments (8)
version.txt (1)

1-1: LGTM! Version bump is appropriate.

The version increment from v2.17.29 to v2.17.30 aligns with the serialization and logging improvements in this PR.

apps/web/utils/reply-tracker/label-helpers.ts (3)

40-40: LGTM! Cleaner logging with provider.name.

This change aligns with the new toJSON() serialization method and produces cleaner, more focused log entries.


113-113: LGTM! Consistent logging approach.

Using provider.name instead of the full provider object improves log readability and aligns with the serialization changes.


124-142: LGTM! Stricter validation prevents runtime errors.

The logic change from checking labelId || label to requiring labelId is correct and more robust. Since labelMessageAndSync requires labelId: string (non-optional), this prevents passing undefined values and ensures the operation only proceeds when properly configured.

apps/web/utils/email/microsoft.ts (1)

78-80: LGTM! Clean serialization implementation.

The toJSON() method correctly implements the interface requirement and provides clear provider identification with type: "OutlookProvider".

apps/web/utils/email/google.ts (1)

81-83: LGTM! Consistent serialization implementation.

The toJSON() method correctly implements the interface requirement and provides clear provider identification with type: "GmailProvider".

apps/web/utils/email/types.ts (1)

46-46: LGTM! Well-designed serialization interface.

The toJSON() method addition enables clean serialization of provider metadata for logging and debugging. The return type { name: string; type: string } provides essential identification while keeping the serialized output minimal.

apps/web/utils/__mocks__/email-provider.ts (1)

39-39: LGTM! Appropriate mock implementation.

The toJSON() mock correctly implements the interface with type: "MockEmailProvider", which appropriately distinguishes mock providers from real implementations in test environments.


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.

1 issue found across 6 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="apps/web/utils/__mocks__/email-provider.ts">

<violation number="1" location="apps/web/utils/__mocks__/email-provider.ts:39">
`toJSON` should reflect the mock provider&#39;s actual name. Because overrides can change `name` (e.g., the mock Outlook provider), this hard-coded &quot;google&quot; makes the serialized data incorrect.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@elie222 elie222 merged commit 5163e11 into main Nov 3, 2025
17 checks passed
@elie222 elie222 deleted the fix/logger branch November 3, 2025 19:46
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

Comments