Skip to content

Conversation

@ArtyomSavchenko
Copy link
Member

Screenshot 2025-11-25 at 11 23 07

Copy link

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 PR fixes a runtime error where array methods (like .filter()) were called on non-array values in operator functions. The fix adds defensive validation checks to ensure fields are arrays before performing array operations, and numbers before performing numeric operations.

Key changes:

  • Added Array.isArray() checks in $pull and $update operators before calling array methods
  • Added numeric type validation in $inc operator to prevent invalid arithmetic operations
  • Added comprehensive test coverage for error handling scenarios with invalid input types

Reviewed changes

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

File Description
packages/core/src/operator.ts Added validation guards with error reporting for $pull, $update, and $inc operators to handle non-array and non-numeric values
packages/core/src/tests/operator.test.ts Added comprehensive test suite covering edge cases for invalid input types (strings, objects, null, NaN)

@ArtyomSavchenko ArtyomSavchenko merged commit c5066da into main Nov 25, 2025
6 checks passed
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.

3 participants