Skip to content

Enable AuthJS debug#619

Merged
edulelis merged 1 commit intoelie222:stagingfrom
edulelis:staging-test-select-account-prompt
Aug 1, 2025
Merged

Enable AuthJS debug#619
edulelis merged 1 commit intoelie222:stagingfrom
edulelis:staging-test-select-account-prompt

Conversation

@edulelis
Copy link
Collaborator

@edulelis edulelis commented Aug 1, 2025

Summary by CodeRabbit

  • Chores
    • Enabled debug mode for authentication to provide more detailed logging during sign-in and sign-out processes.

@vercel
Copy link

vercel bot commented Aug 1, 2025

@edulelis is attempting to deploy a commit to the Inbox Zero OSS Program Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Walkthrough

The change updates the authentication configuration by enabling debug mode, switching the debug property from false to true within the getAuthOptions function. No other logic, signatures, or control flow are affected.

Changes

Cohort / File(s) Change Summary
Authentication Debug Setting
apps/web/utils/auth.ts
Enabled debug mode in NextAuth configuration by setting debug: true.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

Hopping through the code, I see,
Debug mode set for all to be.
Now logs will bloom, details in view,
Troubleshooting made fresh and new!
With every hop, a clearer sight—
Bugs beware, we’ll fix you right! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19390fd and 4bf10c0.

📒 Files selected for processing (1)
  • apps/web/utils/auth.ts (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/auth.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/auth.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/auth.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/auth.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/auth.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/auth.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/auth.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/auth.ts
🧠 Learnings (5)
📚 Learning: applies to apps/web/app/api/**/*.{ts,js} : review all new witherror usage in api routes to ensure cu...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.968Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Review all new withError usage in API routes to ensure custom authentication is implemented where required.

Applied to files:

  • apps/web/utils/auth.ts
📚 Learning: applies to apps/web/app/api/**/*.{ts,js} : all api route handlers in 'apps/web/app/api/' must use au...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.968Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : All API route handlers in 'apps/web/app/api/' must use authentication middleware: withAuth, withEmailAccount, or withError (with custom authentication logic).

Applied to files:

  • apps/web/utils/auth.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : use descriptive console.debug statements for generated ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use descriptive console.debug statements for generated content in LLM-related tests

Applied to files:

  • apps/web/utils/auth.ts
📚 Learning: applies to apps/web/**/{.env.example,env.ts} : client-side environment variables: prefix with `next_...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/**/{.env.example,env.ts} : Client-side environment variables: Prefix with `NEXT_PUBLIC_`

Applied to files:

  • apps/web/utils/auth.ts
📚 Learning: applies to apps/web/env.ts : client-side environment variables must be prefixed with `next_public_` ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-07-18T15:04:50.520Z
Learning: Applies to apps/web/env.ts : Client-side environment variables must be prefixed with `NEXT_PUBLIC_` and added to both the `client` and `experimental__runtimeEnv` sections in `apps/web/env.ts`.

Applied to files:

  • apps/web/utils/auth.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). (2)
  • GitHub Check: Static Code Analysis Js
  • GitHub Check: Jit Security

Comment on lines 83 to 85
export const getAuthOptions: () => NextAuthConfig = () => ({
debug: false,
debug: true,
providers: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Unconditional debug: true will emit verbose console logs in production – leaks PII and breaches repo lint rules

next-auth prints every request, token, and account object via console.* when debug is enabled.

  1. That contravenes the coding-guideline “Don’t use console.”
  2. Access/refresh tokens and user e-mails may land in server logs, violating the principle of least-privilege and triggering compliance concerns (GDPR/PII).

Gate the flag to non-production environments and/or rely on the scoped logger instead:

-export const getAuthOptions: () => NextAuthConfig = () => ({
-  debug: true,
+export const getAuthOptions: () => NextAuthConfig = () => ({
+  // Enable AuthJS debug logs only during local development
+  debug: env.NODE_ENV !== "production",
   providers: [

(or remove the flag and uncomment the custom logger block).


🏁 Script executed:

#!/bin/bash
# Display the definition of getAuthOptions and any debug flags in auth.ts
rg -n "getAuthOptions" -A5 apps/web/utils/auth.ts || true
rg -n "debug" -A2 apps/web/utils/auth.ts || true

Length of output: 708


🏁 Script executed:

#!/bin/bash
# Check environment variable usage and imports in auth.ts
rg -n "env\." -A2 apps/web/utils/auth.ts || true
rg -n "import.*env" -A1 apps/web/utils/auth.ts || true

# Check for existing logger usage or imports
rg -n "logger" -A5 apps/web/utils/auth.ts || true

# Display the top of the file to inspect imports
head -n 50 apps/web/utils/auth.ts || true

Length of output: 10367


🏁 Script executed:

#!/bin/bash
# Locate the env.ts file
fd env.ts

# Check for NODE_ENV definition and exported variables in env.ts
rg -n "export const env" -A5 apps/web/env.ts || true
rg -n "NODE_ENV" -A2 apps/web/env.ts || true

Length of output: 446


Gate AuthJS debug to non-production

Unconditional debug: true in getAuthOptions will force NextAuth to emit console.* logs (including tokens and user data) in production, violating our “no console” rule and risking PII exposure. Please update as follows in apps/web/utils/auth.ts (around lines 83–85):

 export const getAuthOptions: () => NextAuthConfig = () => ({
-  debug: true,
+  // Enable verbose AuthJS logs only in non-production environments
+  debug: env.NODE_ENV !== "production",
   providers: [

Alternatively, remove the debug flag entirely and enable the custom logger block below (lines 115–125) to route AuthJS logs through our scoped logger.

  • apps/web/utils/auth.ts:83–85 — replace debug: true
  • apps/web/utils/auth.ts:115–125 — uncomment/customize the logger section if you prefer scoped logging
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getAuthOptions: () => NextAuthConfig = () => ({
debug: false,
debug: true,
providers: [
export const getAuthOptions: () => NextAuthConfig = () => ({
// Enable verbose AuthJS logs only in non-production environments
debug: env.NODE_ENV !== "production",
providers: [
🤖 Prompt for AI Agents
In apps/web/utils/auth.ts around lines 83 to 85, the debug flag is set
unconditionally to true, causing sensitive logs in production. Modify the debug
setting to be true only in non-production environments by checking the NODE_ENV
variable or remove the debug flag entirely. If you remove it, uncomment and
customize the logger block around lines 115 to 125 to route AuthJS logs through
the scoped logger instead of using console logs.

@edulelis edulelis merged commit 9b65228 into elie222:staging Aug 1, 2025
9 of 11 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

Comments