fix: Fixes digest validation issues#576
Conversation
|
@edulelis is attempting to deploy a commit to the Inbox Zero Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe updates adjust how the Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.tsxInstructions used from: Sources:
**/*.{ts,tsx}Instructions used from: Sources:
🧠 Learnings (2)📓 Common learningspackages/resend/emails/digest.tsx (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). (2)
🔇 Additional comments (6)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
apps/web/app/api/resend/digest/validation.ts (1)
33-35: Consider adding constraints to the flexible schemaWhile the flexible category approach is good for extensibility, consider adding reasonable constraints to prevent potential issues:
Add validation constraints for category names and limits:
-export const digestCategorySchema = z.string(); +export const digestCategorySchema = z.string().min(1).max(50).regex(/^[a-zA-Z0-9]+$/); -export const digestSchema = z.record(z.string(), z.array(digestItemSchema).optional()); +export const digestSchema = z.record( + digestCategorySchema, + z.array(digestItemSchema).max(100).optional() +).refine( + (data) => Object.keys(data).length <= 20, + { message: "Maximum 20 categories allowed" } +);This ensures category names are alphanumeric, reasonably sized, and limits the total number of categories and items per category.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/api/resend/digest/all/route.ts(1 hunks)apps/web/app/api/resend/digest/route.ts(2 hunks)apps/web/app/api/resend/digest/validation.ts(1 hunks)packages/resend/emails/digest.tsx(7 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/web/**/*.{ts,tsx}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- apps/web/CLAUDE.md
apps/web/app/**/*
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- apps/web/CLAUDE.md
**/*.{ts,tsx}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/form-handling.mdc
**/*.tsx
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/data-fetching.mdc
- .cursor/rules/form-handling.mdc
🧠 Learnings (2)
apps/web/app/api/resend/digest/all/route.ts (3)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-06-23T12:27:05.686Z
Learning: Do not hardcode secrets directly in code for cron endpoints; secrets should be managed via environment variables (e.g., CRON_SECRET) and not as plain strings in the source code.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-06-23T12:27:17.978Z
Learning: Cron endpoints must use withError middleware and validate requests with strong secrets (hasCronSecret/hasPostCronSecret); never use weak or predictable secrets.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-06-23T12:27:05.686Z
Learning: Cron endpoints in API routes must be protected with secret validation middleware such as hasCronSecret or hasPostCronSecret to prevent unauthorized access.
apps/web/app/api/resend/digest/validation.ts (2)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-03T12:02:53.001Z
Learning: Applies to **/*.{ts,tsx} : Define validation schemas using Zod
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-06-23T12:27:23.938Z
Learning: Input validation schemas for server actions should be defined using Zod in dedicated .validation.ts files, which can be reused on the client for form validation.
⏰ 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
🔇 Additional comments (2)
packages/resend/emails/digest.tsx (2)
138-149: Well-implemented fallback handling for dynamic categoriesThe fallback mechanism for unknown categories is robust - it provides sensible defaults for name, emoji, color, and href. The use of the nullish coalescing operator for colors ensures the UI remains consistent even with unexpected category values.
Also applies to: 255-255
237-243: Good defensive programming with early returnThe early return when no digest items are present prevents sending empty emails and improves performance by avoiding unnecessary rendering.
| return availableCategories[key as keyof typeof availableCategories]; | ||
| } | ||
| // Fallback for unknown categories | ||
| return { |
There was a problem hiding this comment.
All custom categories will have a gray color with a folder icon, as can be seen in the image attached.
|
@claude review this |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Updated to display categories in 2 * n + 1 rows as can be seen in images below:
Summary by CodeRabbit
Bug Fixes
Refactor