Troubleshooting
Relevant source files
The following files were used as context for generating this wiki page:This document provides guidance for developers on troubleshooting common issues during setup, development, and runtime of the Inbox Zero application. It covers environment configuration, error handling patterns, external service integration, and debugging specific features like the AI Assistant.
The project utilizes several mechanisms for error management, including Next.js error boundaries, centralized server-side error utilities, structured logging, and integration with Sentry for production error tracking. Following the patterns outlined here will help in diagnosing and resolving issues efficiently.
Development Setup
Troubleshooting setup issues often involves verifying requirements, environment variables, and external service configurations.
Initial Setup Flow
This diagram outlines the essential steps for setting up the development environment. Problems often arise from missing dependencies, incorrect environment variables, or misconfigured external services.
Sources: README.md:58-100
Environment Variables
A common source of errors is a misconfigured apps/web/.env file. The application requires several keys for core functionality, authentication, and external services.
| Variable | Description | Source |
|---|---|---|
AUTH_SECRET | A random string for session encryption. | README.md |
EMAIL_ENCRYPT_SECRET | Secret key for encrypting OAuth tokens. | README.md |
EMAIL_ENCRYPT_SALT | Salt for encrypting OAuth tokens. | README.md |
NEXT_PUBLIC_BASE_URL | The public URL of the application (e.g., http://localhost:3000). | README.md |
GOOGLE_CLIENT_ID | Google OAuth Client ID. | README.md |
GOOGLE_CLIENT_SECRET | Google OAuth Client Secret. | README.md |
DATABASE_URL | Connection string for the PostgreSQL database. | README.md |
UPSTASH_REDIS_URL | URL for the Upstash Redis instance. | README.md |
UPSTASH_REDIS_TOKEN | Token for the Upstash Redis instance. | README.md |
GOOGLE_PUBSUB_TOPIC_NAME | The name of the Google Cloud Pub/Sub topic for email notifications. | README.md |
Sources: README.md:103-120, README.md:271-272
Docker Build Issues
When building the application with Docker, NEXT_PUBLIC_* variables are embedded at build time. If NEXT_PUBLIC_BASE_URL is incorrect, the application may fail to make API calls or render links correctly.
Key Points:
NEXT_PUBLIC_BASE_URLmust be passed as a build argument.- You must rebuild the image to change this value; it cannot be changed at runtime.
Example build command:
# For production with your custom domain
docker build \
--build-arg NEXT_PUBLIC_BASE_URL="https://your-domain.com" \
-t inbox-zero \
-f docker/Dockerfile.prod .
Sources: docker/DOCKER_BUILD_GUIDE.md:3-17, README.md:297-307
Error Handling & Reporting
The application has a structured approach to handling and reporting errors, both on the client and server.
Global Error Boundary
The application uses a global error boundary defined in apps/web/app/global-error.tsx to catch unhandled client-side exceptions. This component renders a fallback UI and reports the error to Sentry if configured.
// apps/web/app/global-error.tsx:9-30
"use client";
import { useEffect } from "react";
import * as Sentry from "@sentry/nextjs";
import { ErrorPage } from "@/components/ErrorPage";
export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);
return (
<html>
<body>
<ErrorPage reset={reset} />
</body>
</html>
);
}
Sources: apps/web/app/global-error.tsx:9-30
Server-Side Error Handling
Server-side error handling is centralized through middleware and dedicated patterns for server actions.
API Route Error Handling
API routes are wrapped with middleware like withEmailAccount which centralizes authentication, authorization, and error handling. This avoids repetitive try/catch blocks in every route.
// Example from apps/web/CLAUDE.md
// No need for try/catch in GET routes when using middleware
export const GET = withEmailAccount(async (request) => {
const { emailAccountId } = request.auth;
const result = await getData({ emailAccountId });
return NextResponse.json(result);
});
Sources: apps/web/CLAUDE.md:60-75, apps/web/CLAUDE.md:180-181
Server Action Error Handling
Server actions use next-safe-action for mutations. This library provides a structured way to handle success and error states on the client. The recommended pattern is to check for result?.serverError and display a toast notification.
This diagram shows the flow of a client-side form submission using a server action.
Sentry Integration
Sentry is used for production error tracking. It is configured in apps/web/next.config.ts.
Configuration Highlights:
- Enabled if
NEXT_PUBLIC_SENTRY_DSN,SENTRY_ORGANIZATION, andSENTRY_PROJECTare set. tunnelRoute: "/monitoring"is used to proxy Sentry requests and circumvent ad-blockers.- Source maps are hidden from client bundles for security.
- Automatic instrumentation for Vercel Cron Monitors is enabled.
// apps/web/next.config.ts:252-276
const sentryConfig = {
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
};
Sources: apps/web/next.config.ts:252-276
AI Assistant Troubleshooting
The AI Assistant involves complex interactions between the client, server actions, and LLM providers. Debugging this feature often requires inspecting logs.
Structured Logging
The application uses a createScopedLogger utility to provide contextual logs. When troubleshooting the AI assistant, these logs are critical. For example, in processUserRequest, errors during rule updates or tool calls are explicitly logged with context like emailAccountId, userId, and ruleName.
This diagram illustrates how processUserRequest handles a tool call to update a rule, including the logging step on failure.
Sources: apps/web/utils/ai/assistant/process-user-request.ts:101-118
Tool Call Failures
If the AI assistant fails to perform an action, check the logs for errors within the execute function of the specific tool. For instance, if update_rule fails, the logs will contain the ruleName, the data that was being updated, and the error message from Prisma or the database.
Sources: apps/web/utils/ai/assistant/process-user-request.ts:101-118
Common Issues & FAQs
This section covers common questions and issues that may arise.
| Question | Answer | Source |
|---|---|---|
| Which email providers are supported? | Gmail, Google Workspace, and Microsoft Outlook. | apps/web/app/(landing)/home/FAQs.tsx:4-7 |
| Is this a replacement for my email client? | No, it is used alongside your existing client (Google or Outlook). | apps/web/app/(landing)/home/FAQs.tsx:9-12 |
| How can I get premium features for testing? | Set your email in the ADMINS environment variable, then upgrade yourself at the /admin page. | README.md:267-269 |
| How do I get real-time email updates in development? | Use a service like ngrok to expose your local instance, then configure the Google Pub/Sub subscription to point to your ngrok URL. | README.md:278-286 |
| How do I run tests? | pnpm test for general tests, pnpm test-ai for AI-specific tests. | apps/web/CLAUDE.md:5-8 |
Sources: apps/web/app/(landing)/home/FAQs.tsx, README.md, apps/web/CLAUDE.md