parse-server
parse-server copied to clipboard
fix: LiveQuery throws on `create` event using `Parse.Query.containedIn` with `null` value in array or using `Parse.Query.equalTo` for `Parse.Object` with key value `null`
Pull Request
- Report security issues confidentially.
- Any contribution is under this license.
- Link this pull request to an issue.
Issue
Live query throw error if we create subsciption for
ParentObjectQuery.containedIn('childs', [...childs,null])and a ParentObject is created withParentObject.set('childs',[newChild]ParentObjectQuery.equalTo('child', child)and a ParentObject is created withParentObject.set('child',null)
Closes: FILL_THIS_OUT
Approach
Add not null and not object check before doing the actual checks
Tasks
- [x] Add tests
Summary by CodeRabbit
- Tests
- Added new test cases to ensure live queries involving pointer fields and null values operate reliably without causing server errors or crashes.
- Bug Fixes
- Improved stability by adding checks to prevent errors when handling null or undefined pointer values in live queries.
I will reformat the title to use the proper commit message syntax.
🚀 Thanks for opening this pull request!
❌ Please fill out all fields with a placeholder FILL_THIS_OUT. If a field does not apply to the pull request, fill in n/a or delete the line.
📝 Walkthrough
Walkthrough
Two new focused test cases were added to the ParseLiveQuery test suite. These tests configure the server to enable live queries on the TestObject class and start the live query server. The first test examines the server's stability when handling a containedIn constraint on a pointer array field, ensuring no crashes occur when saving objects with different pointer arrays. The second test checks the server's behavior with an equalTo constraint on a pointer field, specifically when new objects are created with a null value. Both tests focus on confirming server robustness in handling pointer fields and null values. Additionally, two null checks were added in pointer comparison logic within the live query utility functions to prevent runtime errors.
Changes
| File(s) | Change Summary |
|---|---|
| spec/ParseLiveQuery.spec.js | Added two focused test cases verifying live query stability with pointer array and pointer field constraints involving null values. |
| src/LiveQuery/QueryTools.js | Added null checks in pointer comparison functions (contains and matchesKeyConstraints) to avoid runtime errors from null or undefined pointers. |
Sequence Diagram(s)
sequenceDiagram
participant TestCase as Test Case
participant Server as Server
participant LiveQuery as Live Query Server
participant Client as Client
TestCase->>Server: Configure live query for TestObject
TestCase->>LiveQuery: Start live query server
Client->>LiveQuery: Subscribe to query (with pointer constraint)
Client->>Server: Save new TestObject (with pointer array or null)
LiveQuery->>Client: Emit 'create' event (if applicable)
Note right of LiveQuery: Ensure no server errors or crashes
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
:tada: Snyk checks have passed. No issues have been found so far.
:white_check_mark: security/snyk check is complete. No issues have been found. (View Details)
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 93.00%. Comparing base (
0db3a6f) to head (a86e19a). Report is 1 commits behind head on alpha.
Additional details and impacted files
@@ Coverage Diff @@
## alpha #9744 +/- ##
=======================================
Coverage 93.00% 93.00%
=======================================
Files 187 187
Lines 15082 15082
Branches 174 174
=======================================
Hits 14027 14027
Misses 1043 1043
Partials 12 12
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
The title could have been better but I'm out of ideas
@mtrezza This is also a bug. added a fix