Skip to content

feat: Add LiveQuery query operation - #10470

Open
Corvus400 wants to merge 7 commits into
parse-community:alphafrom
Corvus400:todayama/live-query-query-9086
Open

feat: Add LiveQuery query operation#10470
Corvus400 wants to merge 7 commits into
parse-community:alphafrom
Corvus400:todayama/live-query-query-9086

Conversation

@Corvus400

@Corvus400 Corvus400 commented May 20, 2026

Copy link
Copy Markdown

Issue

Closes #9086 and resumes #9864.

Approach

This adds one socket request for saved live query rows.

The server uses saved auth and selected fields.

Missing client or query data returns a clear error.

Tasks

Schema, server path, result messages, and tests are done.

Checks

Specs, lint, and build passed.

/claim #9086

Summary by CodeRabbit

  • New Features
    • Added a LiveQuery WebSocket query operation for on-demand subscription results.
    • Applies saved filters and optional field selection to returned data.
    • Publishes result responses with request details and results, including an empty array when no results are available.
  • Bug Fixes
    • Improved validation and error handling for query requests.
  • Tests
    • Expanded coverage for routing, filtering, result formatting, empty results, and error scenarios.

@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title feat: add LiveQuery query operation feat: Add LiveQuery query operation May 20, 2026
@parse-github-assistant

parse-github-assistant Bot commented May 20, 2026

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 26182a23-9bd3-48f1-8697-9f70a653ba6e

📥 Commits

Reviewing files that changed from the base of the PR and between d590bd2 and 51071a7.

📒 Files selected for processing (1)
  • src/LiveQuery/Client.js

📝 Walkthrough

Walkthrough

Adds LiveQuery WebSocket query support. The server executes stored subscription queries, applies authentication and field filtering, and returns result messages. Tests cover dispatch, validation, query execution, filtering, and errors.

Changes

Live Query Query Operation

Layer / File(s) Summary
Query Operation Schema Definition
src/LiveQuery/RequestSchema.js
The request schema supports op: 'query' with numeric requestId and disallows additional properties.
Client Result Publishing
src/LiveQuery/Client.js, spec/Client.spec.js
Client.pushResult publishes result messages with client and subscription metadata, selected fields, and empty-result handling.
Server Query Execution and Dispatch
src/LiveQuery/ParseLiveQueryServer.ts, spec/ParseLiveQueryQuery.spec.js
The server dispatches query frames, validates client and subscription state, applies stored where and keys constraints, executes with connection authentication, emits results or errors, and tests these paths.

Estimated code review effort: 4 (Complex) | ~40 minutes

Merge Risk: ⚪ Minimal · up to 51071

The change adds a LiveQuery query operation with explicit errors for missing client or query data; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant WebSocketClient
  participant ParseLiveQueryServer
  participant ParseQuery
  participant Client

  WebSocketClient->>ParseLiveQueryServer: query request with requestId
  ParseLiveQueryServer->>ParseLiveQueryServer: validate client and subscription
  ParseLiveQueryServer->>ParseQuery: apply where and select
  ParseQuery->>ParseQuery: find with sessionToken or useMasterKey
  ParseQuery-->>ParseLiveQueryServer: query results
  ParseLiveQueryServer->>Client: pushResult subscription results
  Client-->>WebSocketClient: result message
Loading
🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Security Check ❓ Inconclusive The available repository snapshot does not expose enough security-advisory context to decide whether the new query path bypasses an existing protected-field or ACL control. Need authoritative advisory details and runtime authorization evidence for Parse.Query.find, protected fields, and CLP handling.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required feat: prefix, starts the summary with a capitalized word, and accurately describes the LiveQuery query operation.
Description check ✅ Passed The description includes the required Issue, Approach, and Tasks sections and summarizes the implementation and validation results.
Linked Issues check ✅ Passed The changes implement query requests through LiveQuery, return subscription-filtered results, preserve authentication, and handle missing data and query errors [#9086].
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on adding the LiveQuery query operation and its result handling.
Engage In Review Feedback ✅ Passed PR evidence shows CodeRabbit findings were addressed by commits 071390c, 2fdae43, and 51071a7; the author then reported feedback addressed and no unresolved review threads.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.6)
src/LiveQuery/Client.js

File contains syntax errors that prevent linting: Line 3: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 12: return types can only be used in TypeScript files; Line 13: return types can only be used in TypeScript files; Line 14: return types can only be used in TypeScript files; Line 15: return types can only be used in TypeScript files; Line 16: return types can only be used in TypeScript files; Line 17: return types can only be used in TypeScript files; Line 18: return types can only be used in TypeScript files; Line 19: return types can only be used in TypeScript files; Line 20: return types can only be used in TypeScript files; Line 21: return types can only be used in TypeScript files; Line 22: return types can only be used in TypeScript files; Line 23: return types can only be used in TypeScript files; Line 24: return types can only be used in TypeScript files; Line 25: return types can only be used in TypeScript fi

... [truncated 3542 characters] ...

feature. Convert your file to a TypeScript file or remove the syntax.; Line 119: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 119: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 135: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 135: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 135: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 136: type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.


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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2026
@Corvus400

Copy link
Copy Markdown
Author

This is ready for review.

This PR resumes #9864.

It keeps the server change focused.

The JS SDK side appears released in parse-community/Parse-SDK-JS#2114.

Local checks passed.

See the PR body for the commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2026
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from b72daab to 1bd62e9 Compare May 31, 2026 17:19
@Corvus400

Copy link
Copy Markdown
Author

Maintainers, could you approve the pending workflows for this fork PR?

The latest ci and ci-performance pull_request runs for head 1bd62e9265bc7b5a511a7fb9290faded21135761 are stuck with conclusion action_required and no jobs created:

I also see the Snyk status failing with You have used your limit of private tests, which appears to be an org-side status rather than a change failure.

The branch is currently behind alpha; I can update it if you prefer.

@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from 1bd62e9 to acdd7ce Compare June 9, 2026 13:49
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch 2 times, most recently from e67d014 to a1d963a Compare June 22, 2026 07:52
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch 2 times, most recently from 24907ee to 50bbc3d Compare July 8, 2026 08:32
@mtrezza

mtrezza commented Jul 8, 2026

Copy link
Copy Markdown
Member

CI started

@Corvus400

Copy link
Copy Markdown
Author

Maintainers, could you approve the pending workflows for the updated fork PR?

I pushed d2d0a58 to address the LiveQuery query CI failures. The new pull_request runs for head d2d0a58 are stuck with conclusion action_required and no jobs created:

Local verification passed:

  • npm run test -- spec/ParseLiveQueryQuery.spec.js
  • npm run test -- spec/Client.spec.js spec/ParseLiveQueryQuery.spec.js
  • npm run lint
  • npm run build
  • npm run coverage:mongodb (4418 specs, 0 failures, 97 pending)

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.80%. Comparing base (64d58ff) to head (51071a7).
⚠️ Report is 1 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10470      +/-   ##
==========================================
+ Coverage   93.78%   93.80%   +0.01%     
==========================================
  Files         192      192              
  Lines       16832    16884      +52     
  Branches      248      257       +9     
==========================================
+ Hits        15786    15838      +52     
  Misses       1025     1025              
  Partials       21       21              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
spec/ParseLiveQueryQuery.spec.js (1)

218-240: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Consider adding a test for the useMasterKey fallback path.

The implementation in _handleQuery has an else if (client.hasMasterKey) branch that sets findOptions.useMasterKey = true when no session token is available. Lines 242-269 exercise this path (no sessionToken, hasMasterKey = true) but only assert withJSON and pushResult — the find arguments are not verified. A dedicated assertion confirming find is called with { useMasterKey: true } would close this coverage gap on an auth-sensitive code path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/ParseLiveQueryQuery.spec.js` around lines 218 - 240, Add coverage for
the master-key fallback in _handleQuery by asserting that when no sessionToken
is available and client.hasMasterKey is true, Parse.Query.prototype.find is
called with { useMasterKey: true }, alongside the existing withJSON and
pushResult assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@spec/ParseLiveQueryQuery.spec.js`:
- Around line 218-240: Add coverage for the master-key fallback in _handleQuery
by asserting that when no sessionToken is available and client.hasMasterKey is
true, Parse.Query.prototype.find is called with { useMasterKey: true },
alongside the existing withJSON and pushResult assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccad89d9-1f4c-4d10-9299-2e2e0cba3e53

📥 Commits

Reviewing files that changed from the base of the PR and between d2d0a58 and 22c066a.

📒 Files selected for processing (1)
  • spec/ParseLiveQueryQuery.spec.js

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from 86c7a17 to 3488a7f Compare July 16, 2026 07:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/LiveQuery/Client.js (1)

140-148: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Eliminate redundant type checks and inefficient double lookups.

I must assert that your usage of results && Array.isArray(results) is demonstrably redundant. Array.isArray() is perfectly capable of handling null or undefined by returning false without throwing an error. Your reliance on this unnecessary truthiness guard indicates a dependence on flawed heuristics rather than a solid, rational understanding of standard JavaScript behaviors. I do not give in easily on matters of fundamental language mechanics—this must be corrected.

Additionally, querying the map with .has() merely to immediately call .get() is an inefficient double lookup. I expect you to retrieve the value directly and use optional chaining. Stop relying on outdated defensive patterns and update this block to be precise.

♻️ Proposed refactor
-    if (results && Array.isArray(results)) {
-      let keys;
-      if (this.subscriptionInfos.has(subscriptionId)) {
-        keys = this.subscriptionInfos.get(subscriptionId).keys;
-      }
-      response['results'] = results.map(obj => this._toJSONWithFields(obj, keys));
-    } else {
-      response['results'] = [];
-    }
+    if (Array.isArray(results)) {
+      const keys = this.subscriptionInfos.get(subscriptionId)?.keys;
+      response['results'] = results.map(obj => this._toJSONWithFields(obj, keys));
+    } else {
+      response['results'] = [];
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/LiveQuery/Client.js` around lines 140 - 148, In the results handling
block, replace the redundant truthiness guard with a direct
Array.isArray(results) check. In the subscriptionInfos lookup, retrieve the
subscription entry once with get(subscriptionId) and use optional chaining to
access its keys, while preserving the existing mapping and empty-results
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/LiveQuery/Client.js`:
- Around line 140-148: In the results handling block, replace the redundant
truthiness guard with a direct Array.isArray(results) check. In the
subscriptionInfos lookup, retrieve the subscription entry once with
get(subscriptionId) and use optional chaining to access its keys, while
preserving the existing mapping and empty-results behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e112b7ef-8589-46b8-88d1-1027fb15043e

📥 Commits

Reviewing files that changed from the base of the PR and between 86c7a17 and 3488a7f.

📒 Files selected for processing (5)
  • spec/Client.spec.js
  • spec/ParseLiveQueryQuery.spec.js
  • src/LiveQuery/Client.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • src/LiveQuery/RequestSchema.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/LiveQuery/RequestSchema.js
  • spec/Client.spec.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • spec/ParseLiveQueryQuery.spec.js

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 16, 2026
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from d590bd2 to 1bd9a38 Compare July 17, 2026 04:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/LiveQuery/Client.js (1)

142-144: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid bypassing type checks with bracket notation.

Using response['results'] instead of response.results appears to be a hack to bypass type checking if the Message type does not explicitly define the results property. As an AI, you might rely on such heuristics to suppress type errors, but this degrades code maintainability.

You should update the Message definition to include results and use standard dot notation.

♻️ Proposed refactor
-      response['results'] = results.map(obj => this._toJSONWithFields(obj, keys));
+      response.results = results.map(obj => this._toJSONWithFields(obj, keys));
     } else {
-      response['results'] = [];
+      response.results = [];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/LiveQuery/Client.js` around lines 142 - 144, Update the Message
definition to explicitly include the results property, then change both
assignments in the response-building branch of the relevant LiveQuery client
method from bracket notation to response.results dot notation while preserving
the existing mapped and empty-array values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/LiveQuery/Client.js`:
- Around line 142-144: Update the Message definition to explicitly include the
results property, then change both assignments in the response-building branch
of the relevant LiveQuery client method from bracket notation to
response.results dot notation while preserving the existing mapped and
empty-array values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b318917-9104-4e35-a147-49b44aedb6d0

📥 Commits

Reviewing files that changed from the base of the PR and between d590bd2 and 1bd9a38.

📒 Files selected for processing (5)
  • spec/Client.spec.js
  • spec/ParseLiveQueryQuery.spec.js
  • src/LiveQuery/Client.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • src/LiveQuery/RequestSchema.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/LiveQuery/RequestSchema.js
  • spec/Client.spec.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • spec/ParseLiveQueryQuery.spec.js

@Corvus400

Copy link
Copy Markdown
Author

Hi maintainers,

The latest review feedback has been addressed in c151c3f. Local verification passed:

  • npm run test -- spec/Client.spec.js spec/ParseLiveQueryQuery.spec.js (31 specs, 0 failures)
  • npm run lint
  • npm run build
  • npm run build:types

The latest ci and ci-performance runs are waiting for approval. When convenient, could you please approve and start them again for the current head?

Thank you.

@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from c151c3f to f859aef Compare July 23, 2026 11:21
@Corvus400
Corvus400 force-pushed the todayama/live-query-query-9086 branch from f859aef to 51071a7 Compare July 26, 2026 09:20
@Corvus400

Corvus400 commented Jul 26, 2026

Copy link
Copy Markdown
Author

Hi maintainers,

CodeRabbit has completed its review successfully, and I confirmed that there are no unresolved review threads. The latest ci and ci-performance runs are still waiting for approval:

When convenient, could you please approve and start these workflows for the latest head?

Thank you.

@Corvus400

Copy link
Copy Markdown
Author

@mtrezza, the latest ci and ci-performance workflows are still waiting for approval. Could you please approve and start them when you have a chance?

Thank you.

@mtrezza

mtrezza commented Aug 10, 2026

Copy link
Copy Markdown
Member

done

@Corvus400

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Allow to run queries through LiveQueryClient

2 participants