Skip to content
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

Added Null check in case schema.options['type'][0] is undefined #14431

Merged
merged 1 commit into from Mar 14, 2024

Conversation

Atharv-Bobde
Copy link
Contributor

Summary

In the process of creating a new document, I encountered a TypeError. Upon investigating the error stack, it revealed that the issue was related to an undefined property 'ref' during the execution of model.$set in the Mongoose library.

Upon further examination, I noticed that there was a missing null check for schema.options[typeKey][0], where typeKey is a crucial part of the schema. In my case, schema.options[typeKey][0] was undefined, leading to a subsequent error when trying to access the 'ref' property. To address this issue, I have proposed a pull request to the Mongoose repository that includes the necessary null check for schema.options[typeKey][0]. This modification ensures a smoother handling of cases where the referenced type is absent.

@hasezoey hasezoey requested a review from vkarpov15 March 14, 2024 16:01
@vkarpov15 vkarpov15 added this to the 8.2.2 milestone Mar 14, 2024
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@vkarpov15 vkarpov15 merged commit 1aa88a3 into Automattic:master Mar 14, 2024
18 checks passed
@vkarpov15
Copy link
Collaborator

If you're able to provide a repro script that demonstrates this issue, that would be very helpful so we can write a test for this. But this change is sufficiently low risk that I'm comfortable merging and releasing without tests.

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.

None yet

3 participants