Skip to content

Fix/dashboard get data query engine - #230

Merged
yash-pouranik merged 20 commits into
geturbackend:mainfrom
Mansi0905:fix/dashboard-getData-query-engine
Jun 1, 2026
Merged

Fix/dashboard get data query engine#230
yash-pouranik merged 20 commits into
geturbackend:mainfrom
Mansi0905:fix/dashboard-getData-query-engine

Conversation

@Mansi0905

@Mansi0905 Mansi0905 commented May 29, 2026

Copy link
Copy Markdown
Contributor

🚀 Pull Request Description

Fixes #214

🛠️ Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 UI/UX improvement (Frontend only)
  • ⚙️ Refactor / Chore

🧪 Testing & Validation

Backend Verification:

  • I have run npm test in the backend/ directory and all tests passed.
  • I have verified the API endpoints using Postman/Thunder Client.
  • New unit tests have been added (if applicable).

Frontend Verification:

  • I have run npm run lint in the frontend/ directory.
  • Verified the UI changes on different screen sizes (Responsive).
  • Checked for any console errors in the browser dev tools.

📸 Screenshots

image

.


Built with ❤️ for urBackend.

Summary by CodeRabbit

  • New Features

    • Cursor-based pagination for data retrieval and a count-only query option.
  • Bug Fixes

    • Missing project/collection errors now return standardized structured JSON (404/400) for clearer client responses.
  • Improvements

    • Per-project recent-log sampling (capped) for more accurate health/warning calculations.
    • Response shapes standardized across data endpoints.
  • Tests

    • Test mocks updated to align with enhanced query-controller interactions.

Mansi0905 and others added 6 commits May 27, 2026 22:00
…del with required parameters

- Add collection config lookup before calling getCompiledModel
- Pass all 4 required parameters: connection, collectionConfig, projectId, isExternal
- Handle collection not found error properly
- Fixes TypeError: getAllData is not a function in tests
- Update getCompiledModel mock to accept connection, collectionConfig, projectId, isExternal params
- Make mock return a model object with find() method immediately (synchronously)
- Ensure QueryEngine is properly constructed with query parameter
…tibility

- Move QueryEngine operations into try-catch to handle validation errors with statusCode
- Ensure engine variable is accessible after filter/sort/populate operations
- Fix variable scope issue where engine was not accessible for count() call
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

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

Dashboard and Public API controllers: recentLogs aggregation now computes counts from a capped per-project subset; data endpoints return structured 4xx JSON for missing entities and query errors; Public API list endpoint chains QueryEngine.limitFields(); a test mock signature was updated.

Changes

Project and Data Controller Enhancements

Layer / File(s) Summary
Per-project recentLogs aggregation
apps/dashboard-api/src/controllers/project.controller.js
recentLogs aggregation computes errorCount/successCount from a capped per-project log array, aligning health/warning logic with the capped window.
Project endpoints: structured 4xx responses and getData error handling
apps/dashboard-api/src/controllers/project.controller.js
getSingleProject returns structured 404 ({ success:false, data:{}, message: "Project not found." }); getData returns structured 404 for missing project/collection and structured 400 for query/filter errors; insertData returns structured 404 when collection config missing.
Public API: limitFields(), comment cleanup, and test mock update
apps/public-api/src/controllers/data.controller.js, apps/public-api/src/__tests__/data.controller.read.test.js
getAllData now returns structured 404 ({ success:false, data:{}, message }) for missing collection and chains limitFields() in the QueryEngine chain; two inline comments and minor spacing adjusted; Jest getCompiledModel mock signature updated to accept (connection, collectionConfig, projectId, isExternal).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant getCompiledModel
  participant QueryEngine
  participant Database
  participant Pagination
  Client->>getCompiledModel: GET /data?cursor=...&count=true
  getCompiledModel->>QueryEngine: compiled Model + req.query
  QueryEngine->>Database: execute filter, sort, limitFields, populate
  Database-->>QueryEngine: items / count
  QueryEngine->>Pagination: apply cursor logic / nextCursor
  Pagination-->>Client: { success, data: { items, meta }, message }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

NSOC'26, level-3

Suggested reviewers

  • yash-pouranik

"🐰 I hopped through logs both large and small,
Capped counts aligned and responses shaped for all.
Fields limited, cursors chained, tests tuned to call,
A tidy garden of controllers — neat and tall. 🥕"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references the query engine fix for dashboard API data endpoint, which aligns with the main changes in the changeset.
Linked Issues check ✅ Passed All coding requirements from issue #214 are addressed: Public API getAllData includes limitFields() [#214]; Dashboard API getData includes limitFields(), populate(), cursor pagination, count support, and structured response metadata [#214].
Out of Scope Changes check ✅ Passed All changes directly address the query engine integration gaps outlined in issue #214; no extraneous modifications beyond fixing limitFields, populate, pagination, and response structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/dashboard-api/src/controllers/project.controller.js (1)

334-344: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Global $limit before $group may skew per-project health metrics.

The $limit: 100 applies to logs across all projects before grouping. If one project dominates recent activity, other projects receive zero logs and default to "healthy" regardless of their actual error rate.

Consider using $group with $topN (MongoDB 5.2+) or restructuring to limit logs per project rather than globally.

Suggested approach using $topN per project
 const recentLogs = await Log.aggregate([
   { $match: { projectId: { $in: projectIds } } },
   { $sort: { timestamp: -1 } },
-  { $limit: 100 },
   { $group: {
       _id: "$projectId",
+      recentLogs: { $topN: { n: 20, sortBy: { timestamp: -1 }, output: "$status" } },
       errorCount: { $sum: { $cond: [{ $gte: ["$status", 400] }, 1, 0] } },
       successCount: { $sum: { $cond: [{ $lt: ["$status", 400] }, 1, 0] } }
     }
   }
 ]);
🤖 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 `@apps/dashboard-api/src/controllers/project.controller.js` around lines 334 -
344, The pipeline currently applies a global $limit before $group which biases
results (see Log.aggregate and recentLogs); change the aggregation to limit logs
per project instead of globally: keep the initial $match on projectIds, then
$group by "$projectId" and either use $topN (MongoDB 5.2+) to collect the top N
documents per project by timestamp or $push sorted timestamps and $slice to the
most recent N entries, then compute errorCount and successCount from those
per-project arrays (or unwind & $group again) so each project’s health metrics
are derived from its own recent logs rather than from a globally limited set.
🤖 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.

Inline comments:
In `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 786-806: When collectionName === 'users' ensure the password field
cannot be reintroduced by stripping it from the requested field projection
before QueryEngine is constructed: sanitize req.query.fields (handle comma/space
separated lists and single-field values) to remove any occurrence of "password"
(and "-password" variants) and update req.query.fields accordingly (or delete it
if empty) so that baseQuery.select('-password') remains effective; adjust the
logic immediately before creating new QueryEngine(baseQuery, req.query)
(referencing collectionName, baseQuery.select('-password'), req.query.fields and
QueryEngine.limitFields) so limitFields cannot re-include password.

In `@apps/public-api/src/controllers/data.controller.js`:
- Line 244: getAllData currently calls features.sort().limitFields().populate(),
which can drop fields required for populate because QueryEngine.limitFields()
uses this.query.select(fields); either move the populate() call before
limitFields() (i.e., features.sort().populate().limitFields()) so populate runs
on the full document, or modify QueryEngine.limitFields() to detect requested
populate paths and always include their local/match keys in the projection
(ensure the method adds those localField names to the selected fields before
calling this.query.select). Reference: getAllData and QueryEngine.limitFields().

---

Outside diff comments:
In `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 334-344: The pipeline currently applies a global $limit before
$group which biases results (see Log.aggregate and recentLogs); change the
aggregation to limit logs per project instead of globally: keep the initial
$match on projectIds, then $group by "$projectId" and either use $topN (MongoDB
5.2+) to collect the top N documents per project by timestamp or $push sorted
timestamps and $slice to the most recent N entries, then compute errorCount and
successCount from those per-project arrays (or unwind & $group again) so each
project’s health metrics are derived from its own recent logs rather than from a
globally limited set.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06aec9c5-ef1c-4b19-9fcb-1a5f5030e4a7

📥 Commits

Reviewing files that changed from the base of the PR and between e5f0bdf and b346ad5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/controllers/data.controller.js

Comment thread apps/dashboard-api/src/controllers/project.controller.js
Comment thread apps/public-api/src/controllers/data.controller.js
Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
@yash-pouranik

Copy link
Copy Markdown
Member

and fix the coderabbits comments

@Mansi0905
Mansi0905 force-pushed the fix/dashboard-getData-query-engine branch from 5dfce73 to 2034bb7 Compare May 30, 2026 04:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
apps/public-api/src/controllers/data.controller.js (2)

317-376: ⚖️ Poor tradeoff

Response format inconsistent with coding guidelines.

getSingleDoc returns raw res.json(doc) (line 369) and { error: ... } for errors. Per coding guidelines, all API endpoints should return { success: bool, data: {}, message: "" }. The same applies to insertData, updateSingleData, and deleteSingleDoc in this file.

While this PR focuses on getAllData, consider aligning other endpoints for a consistent API contract.

🤖 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 `@apps/public-api/src/controllers/data.controller.js` around lines 317 - 376,
getSingleDoc currently returns raw doc with res.json(doc) and plain error
objects; update it (and similarly insertData, updateSingleData, deleteSingleDoc)
to conform to the API contract { success: boolean, data: object|null, message:
string }. Specifically, change successful responses to res.json({ success: true,
data: doc, message: '' }) (or an appropriate message) and change all error
responses (400/404/500) to res.status(...).json({ success: false, data: null,
message: 'Invalid ID format.' }) etc.; ensure the catch block returns the error
message in message and sets data to null. Locate and update getSingleDoc,
insertData, updateSingleData, deleteSingleDoc to apply this consistent response
shape.

192-193: 💤 Low value

Remove duplicate comment.

Line 192 and 193 both contain // GET ALL DATA.

🧹 Proposed fix
-// GET ALL DATA
 // GET ALL DATA
 module.exports.getAllData = async (req, res) => {
🤖 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 `@apps/public-api/src/controllers/data.controller.js` around lines 192 - 193,
There are two identical comment lines "// GET ALL DATA" duplicated back-to-back;
remove one of the duplicate comment lines so only a single "// GET ALL DATA"
remains above the GET ALL DATA route handler (look for the handler or function
labeled getAllData / the GET ALL DATA comment block) and preserve surrounding
whitespace/formatting.
apps/dashboard-api/src/controllers/project.controller.js (1)

334-362: ⚖️ Poor tradeoff

Reduce per-project memory usage in Log.aggregate (health logs)

The $group stage accumulates an unbounded logs array per projectId via $push and only later $slices to 100, which can cause per-group memory pressure for high-log-volume projects. Use MongoDB 5.2+ $topN in $group to keep only the latest 100 entries:

{
  $group: {
    _id: "$projectId",
    logs: {
      $topN: {
        n: 100,
        sortBy: { timestamp: -1 },
        output: { status: "$status" }
      }
    }
  }
}
🤖 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 `@apps/dashboard-api/src/controllers/project.controller.js` around lines 334 -
362, The aggregation currently uses Log.aggregate with a $group stage that
$push-es all logs per projectId then $slice-s to 100, which can cause large
per-group memory use; replace that $group (the one building "logs") with a
$topN-based group that keeps only the latest 100 entries (sortBy timestamp
descending and output status) so each group never accumulates unbounded arrays,
and remove the subsequent $project that $slice-s the logs; ensure the change is
applied inside the same Log.aggregate pipeline that uses projectIds and
timestamp and requires MongoDB 5.2+.
🤖 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 `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 334-362: The aggregation currently uses Log.aggregate with a
$group stage that $push-es all logs per projectId then $slice-s to 100, which
can cause large per-group memory use; replace that $group (the one building
"logs") with a $topN-based group that keeps only the latest 100 entries (sortBy
timestamp descending and output status) so each group never accumulates
unbounded arrays, and remove the subsequent $project that $slice-s the logs;
ensure the change is applied inside the same Log.aggregate pipeline that uses
projectIds and timestamp and requires MongoDB 5.2+.

In `@apps/public-api/src/controllers/data.controller.js`:
- Around line 317-376: getSingleDoc currently returns raw doc with res.json(doc)
and plain error objects; update it (and similarly insertData, updateSingleData,
deleteSingleDoc) to conform to the API contract { success: boolean, data:
object|null, message: string }. Specifically, change successful responses to
res.json({ success: true, data: doc, message: '' }) (or an appropriate message)
and change all error responses (400/404/500) to res.status(...).json({ success:
false, data: null, message: 'Invalid ID format.' }) etc.; ensure the catch block
returns the error message in message and sets data to null. Locate and update
getSingleDoc, insertData, updateSingleData, deleteSingleDoc to apply this
consistent response shape.
- Around line 192-193: There are two identical comment lines "// GET ALL DATA"
duplicated back-to-back; remove one of the duplicate comment lines so only a
single "// GET ALL DATA" remains above the GET ALL DATA route handler (look for
the handler or function labeled getAllData / the GET ALL DATA comment block) and
preserve surrounding whitespace/formatting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8c3864b-309f-47d7-b6ac-8856473022f8

📥 Commits

Reviewing files that changed from the base of the PR and between b346ad5 and 2034bb7.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/__tests__/data.controller.read.test.js
  • apps/public-api/src/controllers/data.controller.js

…assword bypass, reorder populate before limitFields
@Mansi0905
Mansi0905 requested a review from yash-pouranik May 30, 2026 05:07
@Mansi0905
Mansi0905 force-pushed the fix/dashboard-getData-query-engine branch from 3608807 to c8bbe8f Compare May 30, 2026 05:19
@yash-pouranik

Copy link
Copy Markdown
Member

@coderabbitai
check

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# List all review comments by coderabbitai on PR `#230`
gh pr view 230 --repo geturbackend/urBackend --json reviews,comments

# Also list review comments (inline)
gh api repos/geturbackend/urBackend/pulls/230/comments --jq '.[] | select(.user.login == "coderabbitai") | {id: .id, path: .path, line: .line, body: .body[0:300]}'

Length of output: 44360



@yash-pouranik Here's a summary of the open CodeRabbit comments from the previous review passes. There are new commits since the last review — triggering a fresh review now.


🔴 Actionable (must fix)

1. apps/dashboard-api/src/controllers/project.controller.js (~line 786–806) — Password leak via limitFields()
When collectionName === 'users', baseQuery.select('-password') can be overridden if the client passes ?fields=password. You need to sanitize req.query.fields to strip any "password" / "-password" entry before passing it to new QueryEngine(baseQuery, req.query).

2. apps/public-api/src/controllers/data.controller.js (~line 244) — populate() after limitFields() drops required fields
The chain features.sort().limitFields().populate() causes limitFields() to call this.query.select(fields) which may exclude the local keys needed for populate. Fix: reorder to features.sort().populate().limitFields().


🟡 Nitpick (good to fix)

3. apps/dashboard-api/src/controllers/project.controller.js (~line 334–362) — Unbounded $push + $slice in health log aggregation
$push-ing all logs per project then $slice-ing to 100 can cause high memory use for busy projects. Use MongoDB 5.2+ $topN in the $group stage instead.

4. apps/public-api/src/controllers/data.controller.js (~lines 317–376) — Inconsistent response shape
getSingleDoc, insertData, updateSingleData, deleteSingleDoc return raw docs or { error: ... }. Per coding guidelines, all endpoints should return { success: bool, data: {}, message: "" }.

5. apps/public-api/src/controllers/data.controller.js (~lines 192–193) — Duplicate // GET ALL DATA comment
Two identical comment lines back-to-back — remove one.

✅ Actions performed

Review triggered.

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.

@yash-pouranik

Copy link
Copy Markdown
Member

please fix thiss/
@Mansi0905

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 825-838: The QueryEngine call chain currently calls .limitFields()
before .populate(), which can strip fields needed for populate and break joins;
update the chain that constructs the features variable (new
QueryEngine(baseQuery, safeQuery)) to call .populate() before .limitFields(),
i.e., reorder the method calls so you have
.filter().sort().populate().limitFields() (retaining .populate() behavior and
other methods) to match the public-api pattern and ensure populate() has
required fields available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b83a7a20-d88d-43a0-8aea-09aa12b5f6e9

📥 Commits

Reviewing files that changed from the base of the PR and between 2034bb7 and 25c26c6.

📒 Files selected for processing (2)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/controllers/data.controller.js

Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
@yash-pouranik

Copy link
Copy Markdown
Member

ok to merge? @coderabbitai

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the password sanitization in project.controller.js
echo "=== Password sanitization in getData ==="
rg -n "password|fields|limitFields|QueryEngine" apps/dashboard-api/src/controllers/project.controller.js -A2 -B2 | head -80

echo ""
echo "=== populate/limitFields order in data.controller.js ==="
rg -n "populate\|limitFields\|sort\|features\." apps/public-api/src/controllers/data.controller.js | head -40

echo ""
echo "=== Duplicate GET ALL DATA comment ==="
rg -n "GET ALL DATA" apps/public-api/src/controllers/data.controller.js

echo ""
echo "=== topN vs push+slice in health aggregation ==="
rg -n "topN\|\$push\|\$slice\|\$top" apps/dashboard-api/src/controllers/project.controller.js | head -20

Length of output: 4086


🏁 Script executed:

#!/bin/bash
echo "=== QueryEngine chain in public-api data.controller.js ==="
rg -n "sort|populate|limitFields|features" apps/public-api/src/controllers/data.controller.js -A1 -B1 | head -60

echo ""
echo "=== Health log aggregation (topN / push / slice) ==="
rg -n 'topN|\$push|\$slice|\$top' apps/dashboard-api/src/controllers/project.controller.js | head -20

echo ""
echo "=== Raw aggregation section around line 334-370 ==="
sed -n '320,380p' apps/dashboard-api/src/controllers/project.controller.js

Length of output: 3898



@yash-pouranik Here's the status of all previously flagged items:

# Issue Status
🔴 1 Password leak via limitFields() in getData ✅ Fixed — safeQuery.fields strips password before QueryEngine; baseQuery.select('-password') also applied
🔴 2 populate() after limitFields() drops required fields (public-api) ✅ Fixed — chain is now features.sort().populate().limitFields()
🟡 3 Unbounded $push + $slice in health log aggregation ✅ Fixed — $topN is now used
🟡 5 Duplicate // GET ALL DATA comment ✅ Fixed — only one instance remains
🟡 4 Inconsistent response shape for getSingleDoc, updateSingleData, etc. (public-api) ⚠️ Not verified — minor nitpick, non-blocking

Both critical issues are resolved and the main nitpicks are addressed. The only unverified item (#4, response shape consistency) is a style concern and non-blocking. The PR looks good to merge. ✅

🐇 ᵕ‿ᵕ

@Mansi0905

Copy link
Copy Markdown
Contributor Author

ok to merge? @coderabbitai

Hi @yash-pouranik, all critical and nitpick issues flagged by CodeRabbit have been resolved. The only remaining item (#4 — response shape consistency for getSingleDoc, updateSingleData, deleteSingleDoc) is marked as non-blocking by CodeRabbit. Happy to fix that too if you'd like — just let me know and I'll address it in a follow-up commit.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

The PR description image shows the urBackend local development environment running successfully on http://localhost:5173/ with Vite v8.0.10 ready in 1394 ms.


@Mansi0905 Great work getting everything addressed! Here's the current status:

# Issue Status
🔴 1 Password leak via limitFields() in getData ✅ Fixed
🔴 2 populate() after limitFields() (public-api) ✅ Fixed
🟡 3 Unbounded $push + $slice$topN ✅ Fixed
🟡 5 Duplicate // GET ALL DATA comment ✅ Fixed
🟡 4 Response shape consistency (getSingleDoc, updateSingleData, deleteSingleDoc) ⚠️ Non-blocking

The PR is merge-ready. Both critical issues and the primary nitpicks are resolved.

For item #4, if you'd like to proactively fix it, the pattern to follow is straightforward — replace raw doc returns and { error: ... } shapes with the standard { success: bool, data: {}, message: "" } format, matching what getAllData already returns. That said, it's entirely optional and can be done in a follow-up PR if preferred.

🐇 ᵕ‿ᵕ

@yash-pouranik

Copy link
Copy Markdown
Member

@coderabbitai
what do u mean by res shapein those controllers
is this??
{
success
messsage
}
?

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

The PR description image shows the urBackend local dev environment running successfully on http://localhost:5173/ with Vite v8.0.10.


@yash-pouranik Yes, almost — but it also includes a data field. The full standard shape used in this project is:

{
  "success": true,
  "data": {},
  "message": "Some message here"
}

Here's a concrete before/after for one of the flagged endpoints (getSingleDoc) in apps/public-api/src/controllers/data.controller.js:

Before (raw doc / inconsistent):

return res.status(200).json(doc);
// or on error:
return res.status(404).json({ error: "Document not found" });

After (standard shape):

return res.status(200).json({ success: true, data: doc, message: "Document fetched successfully." });
// or on error:
return res.status(404).json({ success: false, data: {}, message: "Document not found." });

The same pattern applies to updateSingleData and deleteSingleDoc. The getAllData endpoint already does this correctly in the current PR, so these three just need to be brought in line with it.

As noted earlier, this is non-blocking — the PR can merge as-is and this can be cleaned up in a follow-up. Want me to open a GitHub issue to track it?

🐇 ᵕ‿ᵕ

@yash-pouranik

Copy link
Copy Markdown
Member

got it, that was not scope of this PR
u can ignore that
just remove conflict and will merge

@Mansi0905
Mansi0905 force-pushed the fix/dashboard-getData-query-engine branch from db814f0 to f7c95bb Compare June 1, 2026 08:10
@Mansi0905
Mansi0905 force-pushed the fix/dashboard-getData-query-engine branch from dd0bb51 to 01f2f69 Compare June 1, 2026 08:15
@Mansi0905

Copy link
Copy Markdown
Contributor Author

@coderabbitai check

whats stopping the CI/dashboard-api-tests

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get CI checks for PR `#230`
gh pr checks 230 --repo geturbackend/urBackend

echo ""
echo "=== PR run details ==="
gh run list --repo geturbackend/urBackend --branch fix/dashboard-getData-query-engine --limit 5

echo ""
echo "=== Latest failed run logs (dashboard-api-tests job) ==="
# Get the latest run ID
RUN_ID=$(gh run list --repo geturbackend/urBackend --branch fix/dashboard-getData-query-engine --limit 1 --json databaseId --jq '.[0].databaseId')
echo "Latest run ID: $RUN_ID"
gh run view $RUN_ID --repo geturbackend/urBackend --log-failed 2>&1 | head -150

Length of output: 2325


🏁 Script executed:

#!/bin/bash
# Get logs for the specific failed dashboard-api-tests job
gh run view 26743806401 --repo geturbackend/urBackend --log-failed 2>&1 | head -200

echo ""
echo "=== Specific job log ==="
gh api repos/geturbackend/urBackend/actions/jobs/78814087003/logs 2>&1 | head -200

Length of output: 30600



The PR description image shows the urBackend frontend running at http://localhost:5173/ with Vite v8.0.10 — unrelated to the CI failure.


@Mansi0905 Found it. The failure is caused by a syntax error in apps/dashboard-api/src/controllers/project.controller.js at line 2753 (end of file):

SyntaxError: Unexpected end of input

Every test that require()s project.controller crashes immediately — that's why storage.presigned.controller.test.js and project.controller.softDelete.test.js both fail with "Test suite failed to run" rather than individual test failures.

The file has a missing closing } (or )) somewhere near the end. The changes in this PR likely left a block unclosed. To fix it:

  1. Open apps/dashboard-api/src/controllers/project.controller.js
  2. Scroll to the very end of the file (around line 2750+)
  3. Check that every function body, if block, and module.exports = { ... } is properly closed
  4. A quick lint check locally will pinpoint it:
    node --check apps/dashboard-api/src/controllers/project.controller.js

Once the missing brace is added and pushed, the CI should go green. 🐇

@Mansi0905

Copy link
Copy Markdown
Contributor Author

ngl this PR is haunted @yash-pouranik btw ready to merge

@yash-pouranik

Copy link
Copy Markdown
Member

haunted as hell
Thank you.

@yash-pouranik
yash-pouranik merged commit 48ff163 into geturbackend:main Jun 1, 2026
8 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.

Fix: Query Engine integration gaps in Public API and Dashboard API

2 participants