Skip to content

fix: inngest v3 trigger syntax, IDOR in deleteAlert, and cleanup - #93

Open
fuxicodex wants to merge 1 commit into
Open-Dev-Society:mainfrom
fuxicodex:fix/inngest-idor-and-cleanup
Open

fuxicodex wants to merge 1 commit into
Open-Dev-Society:mainfrom
fuxicodex:fix/inngest-idor-and-cleanup

Conversation

@fuxicodex

@fuxicodex fuxicodex commented Sep 21, 2026

Copy link
Copy Markdown

Summary

  • Fix inngest trigger registration (critical): rewrite all four createFunction calls to the v3 three-arg signature (options, trigger, handler). Previously the handler was passed as the trigger argument, leaving fn undefined and triggers as [{}] — so sign-up-email, weekly-news-summary, check-stock-alerts, and check-inactive-users never registered usable triggers and would never fire.
  • Fix IDOR in deleteAlert: the action now resolves the authenticated session user and scopes the delete query to { _id, userId }. Previously any signed-in user could delete another user's alert. Removed the unused toggleAlert helper.
  • Redact Mongo credentials in logs: database/mongoose.ts no longer prints the full MONGODB_URI (which contains username/password); it now prints a redacted host form.
  • Add null guard for nodemailer transporter in reset-password.ts so unconfigured email credentials fail cleanly instead of throwing on null.sendMail().
  • Remove dead code: orphaned WatchlistTable.tsx (168 lines, no imports) plus the now-unused getWatchlistData action.
  • Add regression tests for the deleteAlert fix (authenticated success / unauthenticated rejected / cross-user rejected).

Verification

  • tsc --noEmit (strict): 0 errors (was 11 before)
  • vitest: 82 passed, 4 skipped (includes new deleteAlert tests)
  • Runtime check against inngest 3.47.0 confirmed the old 2-arg form produced triggers: [{}] / fn: undefined and the new 3-arg form produces correct triggers and handler

Notes

Full next build cannot run locally without a MONGODB_URI (page-data collection connects to the DB); verified via git stash that the build failure is pre-existing and unrelated to these changes.

🤖 Generated with FuXi

Summary by CodeRabbit

  • Security

    • Alert deletion now requires authentication and verifies ownership.
    • Database connection logs no longer expose credentials.
  • Bug Fixes

    • Password reset requests now report a clear error when email credentials are unavailable.
    • Added coverage for secure alert deletion scenarios.
  • Changes

    • Removed the watchlist table and its live price-refresh capability.
    • Removed the alert toggling capability.

- rewrite inngest createFunction calls to v3 three-arg signature
  (options, trigger, handler); previously the handler was passed as the
  trigger arg leaving fn undefined and triggers as [{}], so all four
  background functions (welcome email, weekly news, alert checks,
  inactive-user reengagement) never registered triggers
- require the authenticated session user in deleteAlert and scope the
  delete query to that userId, fixing an IDOR that let any signed-in
  user delete another user's alert; drop unused toggleAlert helper
- redact MONGODB_URI credentials in the connect log line
- add null guard for nodemailer transporter in reset-password email
- remove dead WatchlistTable component and unused getWatchlistData
- add deleteAlert regression tests (authenticated / unauthenticated /
  cross-user)

Co-Authored-By: FuXi <fuxicodex@gmail.com>
@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@fuxicodex is attempting to deploy a commit to the ravixalgorithm's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 0c7f16ed-9752-44ce-80b7-b351e7c8f7e3

📥 Commits

Reviewing files that changed from the base of the PR and between c83129d and 7f75cb3.

📒 Files selected for processing (8)
  • __tests__/delete-alert.test.ts
  • __tests__/reset-password-email.test.ts
  • components/watchlist/WatchlistTable.tsx
  • database/mongoose.ts
  • lib/actions/alert.actions.ts
  • lib/actions/finnhub.actions.ts
  • lib/inngest/functions.ts
  • lib/nodemailer/reset-password.ts
💤 Files with no reviewable changes (2)
  • components/watchlist/WatchlistTable.tsx
  • lib/actions/finnhub.actions.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The pull request secures alert deletion, removes watchlist rendering and data loading, updates Inngest trigger registration, adds a password-reset transporter guard, adjusts its test mock, and redacts MongoDB connection logs.

Changes

Alert access control

Layer / File(s) Summary
Authenticated alert deletion
lib/actions/alert.actions.ts, __tests__/delete-alert.test.ts
deleteAlert now requires authentication and matches the alert ID with the session user ID. Tests cover owned, unauthenticated, and non-owned alerts. The exported toggleAlert utility was removed.

Watchlist implementation removal

Layer / File(s) Summary
Remove watchlist refresh path
components/watchlist/WatchlistTable.tsx, lib/actions/finnhub.actions.ts
The watchlist table and its polling-based getWatchlistData loading path were removed.

Inngest registration updates

Layer / File(s) Summary
Migrate Inngest function registration
lib/inngest/functions.ts
All four Inngest functions now receive triggers as separate arguments. Unused static imports and the unused logoUrl constant were removed.

Email handling updates

Layer / File(s) Summary
Guard password-reset email delivery
lib/nodemailer/reset-password.ts, __tests__/reset-password-email.test.ts
Password-reset email delivery now throws when transporter is unavailable. The test mock uses a non-null assertion.

Database logging protection

Layer / File(s) Summary
Redact MongoDB connection logs
database/mongoose.ts
MongoDB connection logging now redacts credentials and falls back to MongoDB if sanitization fails.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: Inngest v3 trigger syntax, the deleteAlert IDOR fix, and related cleanup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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.

This branch has not been deployed

No deployments
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