fix: unified error notification system for user-fixable errors#1183
fix: unified error notification system for user-fixable errors#1183
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughLogger context is threaded through error utilities and callers; error-message APIs were extended to support selective clearing and one-off "action required" email notifications (with unsubscribe tokens). Call sites updated to pass logger and to use the new notification API where applicable. Changes
Sequence DiagramsequenceDiagram
autonumber
participant LLM as LLM/Error Handler
participant ErrMod as Error Messages Module
participant DB as Database
participant Mail as Resend Sender
participant SMTP as Resend Service
Note over LLM,ErrMod: per-request logger + user email/account info included
LLM->>ErrMod: addUserErrorMessageWithNotification({ userId, userEmail, emailAccountId, errorType, errorMessage, logger })
ErrMod->>DB: lookup existing error entry for (userId, errorType)
DB-->>ErrMod: entry (maybe with emailSentAt)
alt email not sent yet
ErrMod->>Mail: render + sendActionRequiredEmail({..., unsubscribeToken })
Mail->>SMTP: deliver email (category: action-required)
SMTP-->>Mail: delivery result
Mail-->>ErrMod: success/failure
ErrMod->>DB: persist/update entry with `emailSentAt` and token (on success)
else already sent
ErrMod->>DB: update/ensure entry exists (no new email)
end
ErrMod-->>LLM: completed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (17)**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Files:
apps/web/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Files:
**/*.ts📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
Files:
**/*.{tsx,ts}📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Files:
**/*.{tsx,ts,css}📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Files:
**/*.{test,spec}.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Files:
!(pages/_document).{jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
Files:
**/{utils,helpers,lib}/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
Files:
apps/web/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Files:
apps/web/**/*.{ts,tsx,js,jsx,json,css}📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Files:
apps/web/**/*.test.{ts,tsx}📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Files:
apps/web/**/*.{example,ts,json}📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Files:
**/*.test.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
Files:
**/*.test.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)
Files:
🧠 Learnings (25)📓 Common learnings📚 Learning: 2025-11-25T14:37:56.430ZApplied to files:
📚 Learning: 2025-11-25T14:38:07.606ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2025-11-25T14:38:07.606ZApplied to files:
📚 Learning: 2025-11-25T14:37:56.430ZApplied to files:
📚 Learning: 2025-11-25T14:37:56.430ZApplied to files:
📚 Learning: 2025-11-25T14:39:23.326ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2025-11-25T14:37:56.430ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2025-12-18T16:37:47.972ZApplied to files:
📚 Learning: 2025-11-25T14:37:56.430ZApplied to files:
📚 Learning: 2025-11-25T14:39:27.909ZApplied to files:
📚 Learning: 2026-01-01T10:42:29.775ZApplied to files:
📚 Learning: 2025-11-25T14:39:23.326ZApplied to files:
📚 Learning: 2025-11-25T14:39:27.909ZApplied to files:
📚 Learning: 2025-11-25T14:39:23.326ZApplied to files:
🧬 Code graph analysis (3)apps/web/utils/auth/cleanup-invalid-tokens.test.ts (1)
apps/web/utils/meeting-briefs/recipient-context.test.ts (1)
apps/web/utils/auth.test.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (6)
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 |
Unify user-fixable error notifications and logging by routing actions and utilities through
|
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/utils/error-messages/index.ts">
<violation number="1" location="apps/web/utils/error-messages/index.ts:70">
P2: Missing `userId` context in `captureException` call. Other similar functions in this file (`clearSpecificErrorMessages`, `addUserErrorMessageWithNotification`) include userId in the extra context for error tracking. This removal makes debugging harder when errors occur in this function.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if (shouldSendEmail) { | ||
| try { | ||
| const config = errorTypeConfig[errorType]; | ||
| const unsubscribeToken = await createUnsubscribeToken({ | ||
| emailAccountId, | ||
| }); | ||
|
|
||
| await sendActionRequiredEmail({ | ||
| from: env.RESEND_FROM_EMAIL, | ||
| to: userEmail, | ||
| emailProps: { | ||
| baseUrl: env.NEXT_PUBLIC_BASE_URL, | ||
| email: userEmail, | ||
| unsubscribeToken, | ||
| errorType: config.label, | ||
| errorMessage, | ||
| actionUrl: config.actionUrl, | ||
| actionLabel: config.actionLabel, | ||
| }, | ||
| }); | ||
|
|
||
| newEntry.emailSentAt = new Date().toISOString(); | ||
| logger.info("Sent action required email", { errorType }); |
There was a problem hiding this comment.
When Resend is not configured (sendEmail returns early because resend is null) the try block in addUserErrorMessageWithNotification still reaches line 214 and sets emailSentAt, so the code never retries notifications even though nothing was delivered. Because sendEmail doesn't throw when the API key is missing, we silently skip notifying the user—there is no log/error via the injected logger and no follow-up email. Please either surface the missing Resend configuration or avoid marking emailSentAt until sendActionRequiredEmail actually sends an email so that the failure is observable and the notification is retried.
Finding type: Logical Bugs
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/utils/error-messages/index.ts
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor error handling in async operations
**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
**/*.{ts,tsx}: For early access feature flags, create hooks using the naming conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g.,inbox-cleaner,pricing-options-2)
Always define types for A/B test variant flags (e.g.,type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
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 TypeScript namespaces
Don't use non-null assertions with the!postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/utils/error-messages/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/utils/error-messages/index.ts
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed
Files:
apps/web/utils/error-messages/index.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma'sselectoption. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. AllfindUnique/findFirstcalls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
AllfindManyqueries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g.,emailAccount: { id: emailAccountId }) to validate ownership
Files:
apps/web/utils/error-messages/index.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/utils/error-messages/index.ts
**/*.{tsx,ts,css}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
apps/web/utils/error-messages/index.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-hidden="true"on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like<marquee>or<blink>
Only use thescopeprop on<th>elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include atitleelement for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
AssigntabIndexto non-interactive HTML elements witharia-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...
Files:
apps/web/utils/error-messages/index.ts
!(pages/_document).{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Don't use the next/head module in pages/_document.js on Next.js projects
Files:
apps/web/utils/error-messages/index.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g.,import groupBy from 'lodash/groupBy')
Files:
apps/web/utils/error-messages/index.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
Logger should be passed as a parameter to helper functions instead of creating their own logger instances
Files:
apps/web/utils/error-messages/index.ts
apps/web/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx,js,jsx}: Use@/path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports
Files:
apps/web/utils/error-messages/index.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Format code with Prettier
Files:
apps/web/utils/error-messages/index.ts
apps/web/**/*.{example,ts,json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/utils/error-messages/index.ts
🧠 Learnings (11)
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use descriptive scoped loggers for each LLM feature, log inputs and outputs with appropriate log levels, and include relevant context in log messages
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : LLM feature functions must import from `zod` for schema validation, use `createScopedLogger` from `@/utils/logger`, `chatCompletionObject` and `createGenerateObject` from `@/utils/llms`, and import `EmailAccountWithAI` type from `@/utils/llms/types`
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:39:08.150Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-11-25T14:39:08.150Z
Learning: Applies to apps/web/app/api/**/*.{ts,tsx} : Use generic error messages instead of revealing internal details; throw `SafeError` instead of exposing user IDs, resource IDs, or system information
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to app/api/**/*.ts : Use `SafeError` for error responses to prevent information disclosure - provide generic messages (e.g., 'Rule not found' not 'Rule {id} does not exist for user {userId}') without revealing internal IDs or ownership details
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:39:27.909Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:27.909Z
Learning: Applies to **/app/api/**/*.ts : Maintain consistent error response format across all API routes to avoid information disclosure while providing meaningful error feedback
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Implement early returns for invalid LLM inputs, use proper error types and logging, implement fallbacks for AI failures, and add retry logic for transient failures using `withRetry`
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Applied to files:
apps/web/utils/error-messages/index.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : User prompts must contain the actual data and context, and should be kept separate from system prompts
Applied to files:
apps/web/utils/error-messages/index.ts
🧬 Code graph analysis (1)
apps/web/utils/error-messages/index.ts (5)
apps/web/utils/logger.ts (1)
Logger(6-6)apps/web/utils/error.ts (1)
captureException(46-76)apps/web/utils/unsubscribe.ts (1)
createUnsubscribeToken(5-21)packages/resend/src/send.tsx (1)
sendActionRequiredEmail(212-237)apps/web/env.ts (1)
env(17-258)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Baz Reviewer
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: test
- GitHub Check: Macroscope - Correctness Check
🔇 Additional comments (4)
apps/web/utils/error-messages/index.ts (4)
1-14: LGTM! Clean imports and type extension.The new imports support the email notification system, and the
emailSentAtfield properly tracks one-time email delivery. The Logger type integration aligns with the coding guideline to pass loggers as parameters.
28-72: LGTM! Logger parameter threading is correct.Both functions now accept
logger: Loggeras a parameter, which aligns with the coding guideline that helper functions should receive loggers rather than create their own instances. The userId context incaptureExceptionat line 70 is properly included.
74-110: LGTM! Well-structured selective error clearing.The function properly clears specific error types with appropriate error handling. The
captureExceptioncall includes bothuserIdanderrorTypesfor debugging context, and the early return pattern for missing users is clean.
121-155: LGTM! Type-safe error configuration.The
errorTypeConfigmapping is properly typed to require all ErrorType values, ensuring compile-time validation that no error type is missing from the configuration. The relative URLs will be correctly combined withbaseUrlin the email template.
User description
Send one-time email notifications when users have API key issues, insufficient credits, or Microsoft auth expiration.
ActionRequiredEmailtemplate for API/auth errors with configurable error type, message, and action buttonaddUserErrorMessageWithNotification()helper that sends email only once per error type (tracksemailSentAtin existingerrorMessagesJSON field)cleanupInvalidTokens()into Outlook client to handle Microsoft auth expiration (clears tokens, sends reconnection email, prevents repeated errors)Generated description
Below is a concise technical summary of the changes proposed in this PR:
graph LR subgraph "@inboxzero/resend" ["@inboxzero/resend"] sendActionRequiredEmail_("sendActionRequiredEmail"):::added ActionRequiredEmail_("ActionRequiredEmail"):::added Footer_("Footer"):::added REACT_EMAIL_COMPONENTS_("REACT_EMAIL_COMPONENTS"):::added sendActionRequiredEmail_ -- "Sends ActionRequiredEmail with error details and unsubscribeToken" --> ActionRequiredEmail_ ActionRequiredEmail_ -- "Embeds Footer providing unsubscribe, support, and privacy links" --> Footer_ ActionRequiredEmail_ -- "Uses react-email components to build actionable error email" --> REACT_EMAIL_COMPONENTS_ Footer_ -- "Uses react-email components to render footer links" --> REACT_EMAIL_COMPONENTS_ classDef added stroke:#15AA7A classDef removed stroke:#CD5270 classDef modified stroke:#EDAC4C linkStyle default stroke:#CBD5E1,font-size:13px end subgraph "inbox-zero-ai" ["inbox-zero-ai"] handleError_("handleError"):::modified addUserErrorMessageWithNotification_("addUserErrorMessageWithNotification"):::added PRISMA_("PRISMA"):::modified RESEND_("RESEND"):::added clearUserErrorMessages_("clearUserErrorMessages"):::modified handleLinkAccount_("handleLinkAccount"):::modified saveTokens_("saveTokens"):::modified handleError_ -- "Replaces silent adds with notifications and emails for AI errors." --> addUserErrorMessageWithNotification_ addUserErrorMessageWithNotification_ -- "Persists error entry with emailSentAt, updating user's errorMessages." --> PRISMA_ addUserErrorMessageWithNotification_ -- "Sends action-required email with unsubscribe token and action link." --> RESEND_ clearUserErrorMessages_ -- "Clears user's errorMessages via Prisma, logging failures." --> PRISMA_ handleLinkAccount_ -- "Clears error messages upon account link, using logger." --> clearUserErrorMessages_ saveTokens_ -- "Clears AI error messages after saving tokens, using logger." --> clearUserErrorMessages_ classDef added stroke:#15AA7A classDef removed stroke:#CD5270 classDef modified stroke:#EDAC4C linkStyle default stroke:#CBD5E1,font-size:13px endImplement a unified error notification system to send one-time email alerts for user-fixable issues like API key problems, insufficient credits, or Microsoft authentication expiration. Enhance error message management by clearing relevant errors when users update AI settings and integrating the new notification flow into LLM error handling and Outlook client token cleanup.
ActionRequiredEmailtemplate and theaddUserErrorMessageWithNotificationhelper.Modified files (6)
Latest Contributors(1)
clearSpecificErrorMessagesto remove errors when AI settings are updated, integratingcleanupInvalidTokensfor Microsoft auth expiration, and ensuring consistent logger propagation.Modified files (7)
Latest Contributors(2)