Skip to content

fix(model): make sure post save error handler gets doc as param on VersionError #15483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025

Conversation

vkarpov15
Copy link
Collaborator

Fix #15480

Summary

Quick fix - apparently need callback(err, this), callback(err) means a null result gets passed to error handling middleware.

Examples

@vkarpov15 vkarpov15 added this to the 8.16.1 milestone Jun 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes issue #15480 by ensuring that the post-save error handler receives the document as a parameter when a VersionError is encountered.

  • In lib/model.js, the error callback in the $__save function now passes the document (this) along with the error.
  • A corresponding test case has been added in test/model.middleware.test.js to verify that the post-save error handler is called with the proper parameters.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/model.middleware.test.js Adds a test case to confirm that the post-save error handler receives the doc param.
lib/model.js Modifies the error callback to pass the document along with the error for VersionError.

@vkarpov15 vkarpov15 merged commit 21666f2 into master Jun 22, 2025
71 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-15480 branch June 22, 2025 17:42
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.

VersionError invokes error middleware with null document on save()
2 participants