Skip to content

feat(common): dual-server db validation for byod config - #371

Merged
yash-pouranik merged 11 commits into
mainfrom
feature/dual-server-db-validation
Aug 4, 2026
Merged

yash-pouranik merged 11 commits into
mainfrom
feature/dual-server-db-validation

Conversation

@yash-pouranik

@yash-pouranik yash-pouranik commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

While adding mongo db connection string in settings, user have to whitelist both the IPs of the microservices.

Summary by CodeRabbit

  • New Features

    • Added secure MongoDB connectivity testing for database configurations.
    • Database setup can verify connections through available dashboard and public services.
    • Displays relevant server IP addresses and access guidance when database access is denied.
  • Bug Fixes

    • Rejects unsafe or unsupported database connection URLs and restricted network targets.
    • Improved timeout handling and clearer connection failure messages.
    • Collects server IPs from multiple endpoints and continues when one is unavailable.
    • Ensures temporary verification connections are closed after testing.

@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ur-backend-web-dashboard Ready Ready Preview Aug 4, 2026 9:18pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
urbackend Skipped Skipped Aug 4, 2026 9:18pm

@coderabbitai

coderabbitai Bot commented Jul 30, 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

The PR adds shared MongoDB URI safety validation, an authenticated Public API database check, bounded local and remote verification, differentiated errors, and dashboard collection of local and public server IPs.

Changes

External database verification

Layer / File(s) Summary
Shared MongoDB URI safety validation
packages/common/src/utils/network.js, packages/common/src/index.js, packages/common/src/utils/connection.manager.js
Adds DNS-based SSRF checks for MongoDB URIs and safe socket lookup. The utilities are exported and used by external database connections.
Authenticated internal verification endpoint
apps/public-api/src/routes/internal.js, apps/public-api/src/app.js, apps/public-api/src/__tests__/internal.test.js
Adds secret-protected /api/internal/test-db handling, temporary Mongoose verification, structured errors, public-IP details, connection cleanup, and route tests.
Dashboard verification and IP discovery
apps/dashboard-api/src/controllers/project.controller.js, apps/dashboard-api/src/__tests__/project.controller.byod.test.js, apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx
Adds bounded local and Public API checks, differentiated failure messages, controller tests, and concurrent server-IP requests that tolerate individual failures.

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

Sequence Diagram(s)

sequenceDiagram
  participant DashboardForm
  participant DashboardAPI
  participant PublicAPI
  participant MongoDB
  DashboardForm->>DashboardAPI: Submit external database configuration
  DashboardAPI->>DashboardAPI: Validate dbUri with isSafeUri
  DashboardAPI->>MongoDB: Verify local dbUri
  DashboardAPI->>PublicAPI: Verify dbUri with x-internal-secret
  PublicAPI->>PublicAPI: Validate dbUri with isSafeUri
  PublicAPI->>MongoDB: Verify temporary connection
  PublicAPI-->>DashboardAPI: Return verification result and serverIp
  DashboardAPI-->>DashboardForm: Return verification result and IP guidance
Loading

Possibly related PRs

Suggested labels: type:security, type:refactor

Suggested reviewers: nitin-kumar-yadav1307

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: dual-server database validation for BYOD configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/dual-server-db-validation

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 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: 7

🧹 Nitpick comments (3)
apps/public-api/src/routes/internal.js (2)

9-20: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Timing-unsafe secret comparison.

providedSecret !== secret is a variable-time string comparison, which is a known side-channel weakness for secret verification.

🔒 Use constant-time comparison
+const crypto = require('crypto');
+
 const internalAuth = (req, res, next) => {
     const secret = process.env.INTERNAL_SECRET;
     if (!secret) {
         console.error("INTERNAL_SECRET is not configured on Public API");
         return res.status(500).json({ success: false, message: "Server misconfiguration" });
     }
     
     const providedSecret = req.headers['x-internal-secret'];
-    if (!providedSecret || providedSecret !== secret) {
+    const provided = Buffer.from(String(providedSecret || ''));
+    const expected = Buffer.from(secret);
+    if (provided.length !== expected.length || !crypto.timingSafeEqual(provided, expected)) {
         return res.status(403).json({ success: false, message: "Forbidden: Invalid internal secret" });
     }
     
     next();
 };
🤖 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/routes/internal.js` around lines 9 - 20, Replace the
variable-time providedSecret !== secret check in the internal-secret middleware
with a constant-time comparison using the appropriate crypto API, ensuring both
values are safely normalized to equal-length byte representations before
comparison. Preserve the existing 403 response for missing or invalid secrets
and the next() path for valid credentials.

30-51: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Temp MongoDB connections aren't closed on the failure path in either service. Both files create a mongoose.createConnection(...) for verification but only call .close() on success; the same cleanup gap exists in both.

  • apps/public-api/src/routes/internal.js#L30-L51: close tempConn in a finally block covering both the success and catch paths.
  • apps/dashboard-api/src/controllers/project.controller.js#L734-L738: apply the same finally-based cleanup to its local tempConn.
🤖 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/routes/internal.js` around lines 30 - 51, Ensure both
verification flows close their temporary MongoDB connections on success and
failure. In apps/public-api/src/routes/internal.js lines 30-51, move tempConn
cleanup into a finally block surrounding the try/catch and remove the
success-only close; apply the same finally-based cleanup to the local tempConn
in apps/dashboard-api/src/controllers/project.controller.js lines 734-738.
apps/public-api/src/app.js (1)

82-84: 🔒 Security & Privacy | 🔵 Trivial

Consider network-level restriction as defense in depth.

/api/internal relies solely on a shared secret header for authorization. If feasible, also restrict this path at the infrastructure layer (VPC/security group, ingress rule) so it's unreachable from the public internet, complementing the secret check.

🤖 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/app.js` around lines 82 - 84, Restrict the /api/internal
route exposed by app.use and the internalRoute registration to trusted internal
network sources at the infrastructure layer, such as VPC, security-group, or
ingress rules, while retaining the existing shared-secret authorization. Ensure
the path is unreachable from the public internet without changing other routes.
🤖 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 726-750: Move the getPublicIp() call out of the main try block and
into the catch block, where dashboardIp is only needed for failure reporting.
Keep the database connection and Public API verification flow unchanged, and
preserve lazy handling consistent with publicApiIp.
- Around line 730-777: Bound the verification flow in the surrounding controller
handler with an overall timeout so local MongoDB verification, remote
`/api/internal/test-db` verification, and fallback `/api/server-ip` lookup
cannot cumulatively exceed the request deadline. Preserve the existing error
classification and IP propagation while ensuring the timeout rejects promptly
and is handled by the existing connection-failure path.
- Around line 741-749: Update updateExternalConfig around the PUBLIC_API_URL and
INTERNAL_SECRET check so external DB confirmation cannot return success when
verification is skipped. Require both configuration values for external DB
updates and fail the operation when either is missing, unless an existing
explicit opt-out is provided; preserve the current axios verification path when
both values are present.
- Around line 755-760: Update the Axios error handling in the project connection
flow around connErr.response.data so only database-URI-specific verification
failures use the returned message; replace internal authentication,
configuration, and other infrastructure errors with a safe user-facing fallback
indicating public API verification failed. Preserve the existing serverIp
extraction behavior.

In `@apps/public-api/src/routes/internal.js`:
- Line 11: Normalize every response in the internal route handlers, including
the branches near the referenced lines, to the mandated { success, data, message
} shape by always including data as an object. Move the failure response’s
serverIp value into data.serverIp, and preserve the existing success status,
message, and payload semantics within data.
- Around line 22-34: Validate dbUri with the existing isSafeUri
restricted-host/internal-network check before mongoose.createConnection in the
/test-db route. Share or reuse that validator from a common module so this
endpoint independently rejects unsafe URIs with an appropriate client error,
while preserving the current connection test for safe URIs.

In `@apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx`:
- Around line 24-33: Update the direct public API request in the server-IP
loading flow around Promise.allSettled to use an AbortController timeout and
validate response.ok before parsing JSON. Ensure a hung request is rejected
within the timeout so the fulfilled dashboard API result can still update
serverIp, while preserving the existing mounted-state and IP aggregation
behavior.

---

Nitpick comments:
In `@apps/public-api/src/app.js`:
- Around line 82-84: Restrict the /api/internal route exposed by app.use and the
internalRoute registration to trusted internal network sources at the
infrastructure layer, such as VPC, security-group, or ingress rules, while
retaining the existing shared-secret authorization. Ensure the path is
unreachable from the public internet without changing other routes.

In `@apps/public-api/src/routes/internal.js`:
- Around line 9-20: Replace the variable-time providedSecret !== secret check in
the internal-secret middleware with a constant-time comparison using the
appropriate crypto API, ensuring both values are safely normalized to
equal-length byte representations before comparison. Preserve the existing 403
response for missing or invalid secrets and the next() path for valid
credentials.
- Around line 30-51: Ensure both verification flows close their temporary
MongoDB connections on success and failure. In
apps/public-api/src/routes/internal.js lines 30-51, move tempConn cleanup into a
finally block surrounding the try/catch and remove the success-only close; apply
the same finally-based cleanup to the local tempConn in
apps/dashboard-api/src/controllers/project.controller.js lines 734-738.
🪄 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 Plus

Run ID: 0a0085f2-567e-4508-a558-433bf643fa84

📥 Commits

Reviewing files that changed from the base of the PR and between 94c9d71 and c5a8b4e.

📒 Files selected for processing (4)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/app.js
  • apps/public-api/src/routes/internal.js
  • apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx

Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
Comment thread apps/dashboard-api/src/controllers/project.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/public-api/src/routes/internal.js Outdated
Comment thread apps/public-api/src/routes/internal.js Outdated
Comment thread apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx

Copilot AI 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.

Pull request overview

This PR adds “dual-server” MongoDB BYOD connectivity validation so external DB connection strings are verified from both the Dashboard API and the Public API, and the UI surfaces both service IPs to whitelist when access is denied.

Changes:

  • Introduces isSafeUri in @urbackend/common to validate DB URIs against restricted/internal IP ranges (SSRF prevention).
  • Adds a new Public API internal endpoint (POST /api/internal/test-db) to verify DB connectivity from the Public API service.
  • Updates the web dashboard DB settings UI to fetch/display both Dashboard API and Public API server IPs.

Reviewed changes

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

Show a summary per file
File Description
packages/common/src/utils/network.js Adds SSRF-oriented URI safety validation (isSafeUri) and exports it.
packages/common/src/index.js Re-exports isSafeUri from common package entrypoint.
apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx Fetches server IPs from both services and displays them together for whitelisting.
apps/public-api/src/routes/internal.js Adds protected internal route to test DB connectivity from Public API.
apps/public-api/src/app.js Mounts the new /api/internal route.
apps/dashboard-api/src/controllers/project.controller.js Updates BYOD DB verification to validate both local and Public API connectivity and improve whitelist messaging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/common/src/utils/network.js Outdated
Comment thread apps/public-api/src/app.js Outdated
Comment thread apps/public-api/src/routes/internal.js Outdated
Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
Comment thread apps/dashboard-api/src/controllers/project.controller.js
Comment thread apps/public-api/src/routes/internal.js
@Nitin-kumar-yadav1307

Copy link
Copy Markdown
Collaborator

whats in dual server validation? @yash-pouranik

@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: 6

🧹 Nitpick comments (1)
apps/dashboard-api/src/controllers/project.controller.js (1)

616-626: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use AppError instead of raw throw new Error(...).

Both the overall-timeout rejection and the missing-configuration rejection use plain Error objects for internal control flow. The coding guidelines for this path require AppError for errors instead of raw throw. Both throws are currently caught internally and mapped to compliant {success, data, message} responses, so there is no client-facing defect today, but aligning with AppError keeps error handling consistent with the rest of the API surface.

As per coding guidelines, "use AppError for errors, never raw throw."

🤖 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 616 -
626, Replace both raw Error instances in the verification Promise flow— the
overall timeout rejection and the missing PUBLIC_API_URL/INTERNAL_SECRET
validation—with AppError instances. Preserve the existing timeout behavior and
compliant success/data/message response mapping.

Source: Coding guidelines

🤖 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 645-668: Update the error classification around the Axios response
handling to explicitly detect Axios failures with no response, using
connErr.isAxiosError and !connErr.response (or the relevant network
timeout/refusal codes), and assign the same "Public API verification failed."
infrastructure message used by the existing response-error branch. Ensure these
failures do not fall through to the default MongoDB URI error.
- Line 636: Update the connection-failure logging around connErr in the project
controller to avoid writing connErr.message directly, since it may contain dbUri
credentials. Log only a safe failure classification, or sanitize the message to
redact connection credentials before passing it to console.error.

In `@packages/common/src/utils/network.js`:
- Around line 38-64: Extend isRestrictedIPv4 to return true for carrier-grade
NAT, documentation/test, multicast, reserved, and broadcast ranges listed in the
review comment. Add the checks alongside the existing IPv4 range checks while
preserving current behavior for all already-restricted ranges.
- Around line 109-148: Update isSafeUri and the downstream
mongoose.createConnection paths to resolve hostnames once, validate every A/AAAA
result, and return or propagate the validated address set for connection use
instead of resolving the original hostname again. Ensure Dashboard API, Public
API /api/internal/test-db, and connection.manager.js pass the pinned safe IP
through MongoDB/Mongoose lookup while preserving rejection of restricted or
unresolved targets.
- Around line 66-87: Update isRestrictedIPv6 to recognize IPv4-mapped addresses
in both dotted-decimal and hexadecimal last-32-bit forms. Parse the mapped IPv6
suffix into its numeric 32-bit value, convert or compare it against the
corresponding IPv4 restriction logic, and preserve existing handling for
loopback, unspecified, link-local, and ULA addresses.
- Around line 109-125: Update isSafeUri to parse MongoDB connection strings with
the project’s MongoDB connection-string parser instead of relying on new URL().
For mongodb:// URIs, iterate through every host in the parsed .hosts collection
and apply the existing hostname, blocked-host, and restricted-IP validation to
each host, while preserving rejection of mongodb+srv:// URIs; continue using URL
parsing for non-MongoDB schemes.

---

Nitpick comments:
In `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 616-626: Replace both raw Error instances in the verification
Promise flow— the overall timeout rejection and the missing
PUBLIC_API_URL/INTERNAL_SECRET validation—with AppError instances. Preserve the
existing timeout behavior and compliant success/data/message response mapping.
🪄 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 Plus

Run ID: b08990de-84bb-424e-a271-0d8dca0e852f

📥 Commits

Reviewing files that changed from the base of the PR and between c5a8b4e and e7c95aa.

📒 Files selected for processing (6)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/app.js
  • apps/public-api/src/routes/internal.js
  • apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx
  • packages/common/src/index.js
  • packages/common/src/utils/network.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web-dashboard/src/components/Settings/DatabaseConfigForm.jsx
  • apps/public-api/src/app.js
  • apps/public-api/src/routes/internal.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 packages/common/src/utils/network.js
Comment thread packages/common/src/utils/network.js
Comment thread packages/common/src/utils/network.js
Comment thread packages/common/src/utils/network.js
@yash-pouranik

Copy link
Copy Markdown
Member Author

whats in dual server validation? @yash-pouranik

@Nitin-kumar-yadav1307

we have 2 servers
dashboard api and publiv api
both have thier own ip address
when user gives their mongo url, they can connect it with dashboard or via rest api or via SDKs. so both server being used

So both servers IP address should be whitlisted in users mongo atlas setting.

@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 (1)
apps/public-api/src/app.js (1)

86-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make /api/internal observable or remove the no-op logger.

logger excludes /api/internal from its completion handler. The new database verification requests therefore produce no request logs or API analytics through this middleware. Add dedicated internal audit logging, or remove logger from this mount if these requests do not require observability.

🤖 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/app.js` at line 86, Update the `/api/internal` mount
involving `logger` so these requests remain observable: either add dedicated
audit logging that records their completion and analytics, or remove `logger`
from the mount if observability is intentionally unnecessary. Do not leave the
current no-op logger middleware in place.
🤖 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/public-api/src/app.js`:
- Line 86: Update the `/api/internal` mount involving `logger` so these requests
remain observable: either add dedicated audit logging that records their
completion and analytics, or remove `logger` from the mount if observability is
intentionally unnecessary. Do not leave the current no-op logger middleware in
place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a0700f2-21f8-4470-8ab5-eaab40b36b4d

📥 Commits

Reviewing files that changed from the base of the PR and between e7c95aa and f7a5d9c.

📒 Files selected for processing (4)
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/app.js
  • apps/public-api/src/routes/internal.js
  • packages/common/src/utils/network.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/public-api/src/routes/internal.js
  • packages/common/src/utils/network.js
  • apps/dashboard-api/src/controllers/project.controller.js

@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

🤖 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 `@packages/common/src/utils/network.js`:
- Around line 169-197: Update the MongoDB connection safety flow around
isSafeUri and createSafeLookup so every topology-discovered replica-set or SRV
endpoint is validated against the existing private/restricted-IP allowlist
before socket creation. Ensure hostname targets use the same constrained DNS
resolution and IP literals cannot bypass validation; preserve rejection of
unsafe destinations rather than allowing unrestricted dynamic lookup.
- Around line 249-258: Update createSafeLookup to honor options.family by
filtering resolvedIps[lowerHost] to IPv4 or IPv6 addresses when requested, while
preserving all validated addresses when no family is specified. When options.all
is true, invoke cb with an array of address records containing address and
family; otherwise return the first matching address with its family as the
scalar lookup result.
🪄 Autofix

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 Plus

Run ID: 5fe35655-bebe-4814-bed3-f689251156a8

📥 Commits

Reviewing files that changed from the base of the PR and between f7a5d9c and d285219.

📒 Files selected for processing (7)
  • apps/dashboard-api/src/__tests__/project.controller.byod.test.js
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/__tests__/internal.test.js
  • apps/public-api/src/routes/internal.js
  • packages/common/src/index.js
  • packages/common/src/utils/connection.manager.js
  • packages/common/src/utils/network.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/public-api/src/routes/internal.js
  • apps/dashboard-api/src/controllers/project.controller.js

Comment thread packages/common/src/utils/network.js
Comment thread packages/common/src/utils/network.js Outdated
@yash-pouranik
yash-pouranik temporarily deployed to feature/dual-server-db-validation - urBackend-frankfrut PR #371 August 4, 2026 20:38 — with Render Destroyed
@vercel
vercel Bot temporarily deployed to Preview – urbackend August 4, 2026 20:38 Inactive

@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

🧹 Nitpick comments (1)
apps/public-api/src/__tests__/internal.test.js (1)

88-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert temporary connection cleanup.

Each case creates a temporary Mongoose connection and supplies close as a mock. Assert that close runs after successful verification, local failure, remote failure, and timeout.

  • apps/public-api/src/__tests__/internal.test.js#L88-L101: Assert mockConn.close after the successful response.
  • apps/dashboard-api/src/__tests__/project.controller.byod.test.js#L105-L123: Assert mockConn.close after local connection rejection.
  • apps/dashboard-api/src/__tests__/project.controller.byod.test.js#L125-L151: Assert mockConn.close after remote verification failure.
  • apps/dashboard-api/src/__tests__/project.controller.byod.test.js#L153-L172: Assert mockConn.close after timeout handling.
🤖 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/__tests__/internal.test.js` around lines 88 - 101, Assert
that the temporary Mongoose connection’s close mock runs in every verification
outcome: after successful verification in
apps/public-api/src/__tests__/internal.test.js lines 88-101, and after local
rejection, remote verification failure, and timeout handling in
apps/dashboard-api/src/__tests__/project.controller.byod.test.js lines 105-123,
125-151, and 153-172. Add the close assertions after each response or
error-handling flow using each test’s mockConn.close.
🤖 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/__tests__/project.controller.byod.test.js`:
- Around line 159-166: Update the test around updateExternalConfig so fake time
advances asynchronously with await jest.advanceTimersByTimeAsync(10000),
allowing the controller to schedule its verification timeout before advancing.
Wrap the fake-timer setup and updatePromise execution in try/finally to always
call jest.useRealTimers(), including when the test fails.

In `@apps/public-api/src/__tests__/internal.test.js`:
- Around line 98-100: Strengthen the response-envelope assertions in
apps/public-api/src/__tests__/internal.test.js lines 98-100 by asserting that
res.body.data is an object. In
apps/dashboard-api/src/__tests__/project.controller.byod.test.js lines 116-122
and 144-150, assert success is false; at lines 168-171, assert success is false
and data is an object. Keep the existing message and status assertions.

---

Nitpick comments:
In `@apps/public-api/src/__tests__/internal.test.js`:
- Around line 88-101: Assert that the temporary Mongoose connection’s close mock
runs in every verification outcome: after successful verification in
apps/public-api/src/__tests__/internal.test.js lines 88-101, and after local
rejection, remote verification failure, and timeout handling in
apps/dashboard-api/src/__tests__/project.controller.byod.test.js lines 105-123,
125-151, and 153-172. Add the close assertions after each response or
error-handling flow using each test’s mockConn.close.
🪄 Autofix

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 Plus

Run ID: c0179f1f-16c8-4a5a-a7b5-e73207945619

📥 Commits

Reviewing files that changed from the base of the PR and between d285219 and 347cce2.

📒 Files selected for processing (3)
  • apps/dashboard-api/src/__tests__/project.controller.byod.test.js
  • apps/public-api/src/__tests__/internal.test.js
  • packages/common/src/utils/network.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/common/src/utils/network.js

Comment thread apps/dashboard-api/src/__tests__/project.controller.byod.test.js Outdated
Comment thread apps/public-api/src/__tests__/internal.test.js
@yash-pouranik
yash-pouranik temporarily deployed to feature/dual-server-db-validation - urBackend-frankfrut PR #371 August 4, 2026 21:17 — with Render Destroyed
@vercel
vercel Bot temporarily deployed to Preview – urbackend August 4, 2026 21:17 Inactive
@yash-pouranik
yash-pouranik merged commit 62e1faf into main Aug 4, 2026
12 checks passed
@yash-pouranik
yash-pouranik deleted the feature/dual-server-db-validation branch August 4, 2026 21:41

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – ur-backend-web-dashboard — f73cabe3 Deployed Aug 4, 2026 by vercel[bot]
Preview – urbackend — f73cabe3 Deployed Aug 4, 2026 by vercel[bot]
feature/dual-server-db-validation - urBackend-frankfrut PR #371 — f73cabe3 Deployed Aug 4, 2026 by yash-pouranik
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