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 to fetch on-demand subscription results.
    • Applies stored subscription where filters (defaults to {}) and optional keys field selection.
    • Publishes result responses including installationId, clientId, requestId, and results (empty array when applicable).
  • Bug Fixes
    • Improved validation, error handling, and suppression of results when query execution fails.
  • Tests
    • Expanded Jasmine coverage for query routing, session-token usage, result shaping, empty-result publishing, 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
📝 Walkthrough

Walkthrough

Adds LiveQuery WebSocket query support through schema validation, stored-subscription query execution, client result publishing, authentication and filtering behavior, and success/error test coverage.

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; tests cover these payloads.
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 the related paths.

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

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

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ 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.
Engage In Review Feedback ❓ Inconclusive Code changes implement the feature, but the repo gives no evidence of reviewer dialogue or feedback engagement. Provide the PR review thread or commit references showing the feedback was discussed and either implemented or retracted.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change and uses the required feat: prefix.
Description check ✅ Passed The description covers the issue, approach, tasks, and verification, though the task list is brief and not checkbox-formatted.
Linked Issues check ✅ Passed The PR implements LiveQuery query execution and result delivery, which addresses the core goal in #9086.
Out of Scope Changes check ✅ Passed The changes stay focused on LiveQuery query support, schema updates, result messages, and tests.
Security Check ✅ Passed Query frames are schema-validated and only execute for an existing client/subscription; results reuse existing auth and field filtering paths.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❌ Patch coverage is 67.92453% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.59%. Comparing base (2625489) to head (d2d0a58).
⚠️ Report is 1 commits behind head on alpha.

Files with missing lines Patch % Lines
src/LiveQuery/ParseLiveQueryServer.ts 61.36% 15 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10470      +/-   ##
==========================================
- Coverage   92.68%   92.59%   -0.09%     
==========================================
  Files         193      193              
  Lines       16986    17039      +53     
  Branches      248      257       +9     
==========================================
+ Hits        15743    15777      +34     
- Misses       1222     1239      +17     
- Partials       21       23       +2     

☔ 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.

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