Skip to content

Add missing next() call in Mongoose pre-save middleware hook (Issue #699)#704

Open
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/699-missing-next-middleware
Open

Add missing next() call in Mongoose pre-save middleware hook (Issue #699)#704
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/699-missing-next-middleware

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Summary

Ensure proper middleware chain execution by calling next() in the pre-save hook. This prevents middleware chain interruption and ensures subsequent hooks are invoked correctly.

Changes

  • Added next parameter to pre-save hook
  • Call next() when password modification check returns early
  • Call next() at end of middleware to allow next hook execution
  • Maintains compatibility with Mongoose middleware chain

Testing

  1. Create a new user and verify password hashing works correctly
  2. Update an existing user without changing password and verify no re-hashing
  3. Update an existing user's password and verify re-hashing occurs
  4. Verify subsequent middleware hooks (if any) execute properly
  5. Check that no middleware chain errors occur

Type of Change

  • Bug fix

Contributor Declaration

This contribution is original work and I have the right to contribute this code to the project. I understand that the project is licensed under its respective license and my contributions will be available under the same license terms.

Closes #699

…itMetricsLab#699)

Ensure proper middleware chain execution by calling next() in the pre-save hook. This prevents middleware chain interruption and ensures subsequent hooks are invoked correctly.

Changes:
- Added next parameter to pre-save hook
- Call next() when password modification check returns early
- Call next() at end of middleware to allow next hook execution
- Maintains compatibility with Mongoose middleware chain

Fixes GitMetricsLab#699
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@anshul23102, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 38 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7eeb8674-306b-4123-9018-8dbc68a926b4

📥 Commits

Reviewing files that changed from the base of the PR and between 53f820b and fcd57ca.

📒 Files selected for processing (1)
  • backend/models/User.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit fcd57ca
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a209d0f1a3d7000085d3fae
😎 Deploy Preview https://deploy-preview-704--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@anshul23102
Copy link
Copy Markdown
Contributor Author

Could the maintainers please add relevant labels to this PR? Suggested labels:

  • gssoc:approved
  • type:bug
  • severity:medium
  • area:backend

This would help with issue tracking and organization. Thank you!

1 similar comment
@anshul23102
Copy link
Copy Markdown
Contributor Author

Could the maintainers please add relevant labels to this PR? Suggested labels:

  • gssoc:approved
  • type:bug
  • severity:medium
  • area:backend

This would help with issue tracking and organization. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reliability: Missing next() call in Mongoose pre-save middleware hook can cause middleware chain interruption

1 participant