Skip to content

Conversation

@dblythy
Copy link
Member

@dblythy dblythy commented Jun 22, 2025

Pull Request

Issue

Closes: #9798

Approach

Adds mechanism to load publicServerUrl on handleParseSession

Tasks

  • Add tests

Summary by CodeRabbit

  • New Features

    • publicServerURL may be a function or Promise, not just a static string.
  • Behavior

    • Async config values are eagerly resolved and re-evaluated on each access so generated links use the current publicServerURL.
    • Configuration keys are ensured loaded before request handling; email validation falls back to resolved values.
    • Validation error for invalid publicServerURL updated to require http:// or https://.
  • Tests

    • Added comprehensive tests for dynamic publicServerURL, error handling, per-access invocation, and email link generation.
  • Documentation

    • Expanded publicServerURL docs/help text to describe async usage and requirements.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jun 22, 2025

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Jun 22, 2025

Warning

Rate limit exceeded

@mtrezza has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3511605 and b508a3a.

📒 Files selected for processing (3)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
📝 Walkthrough

Walkthrough

Adds support for dynamic/async publicServerURL (string | function | Promise), moves async keys to underscored properties, introduces Config.transformConfiguration and Config.loadKeys() to resolve and persist underscored async keys, calls loadKeys() in request middleware before attaching req.config, updates email validation to fall back to _publicServerURL, and adds comprehensive tests for async, thrown/rejected, and per-call resolution behavior.

Changes

Cohort / File(s) Summary
Configuration System
src/Config.js
Added asyncKeys list; static transformConfiguration(serverConfiguration) to move async keys to underscored properties; async loadKeys() to resolve underscored async keys and persist updates to AppCache; integrated transform into put(); added validatePublicServerURL({ publicServerURL, required }); updated validation flows and signatures (including validateControllers to accept _publicServerURL).
Request Middleware
src/middlewares.js
Inserted await config.loadKeys() into handleParseHeaders after app config validation and before attaching req.config, ensuring per-request resolution of async keys.
Routers / Email Validation
src/Routers/UsersRouter.js
Changed Config.validateEmailConfiguration calls to use `publicServerURL: req.config.publicServerURL
Options / Types
src/Options/index.js, src/Options/Definitions.js, src/Options/docs.js, types/Options/index.d.ts
Expanded publicServerURL type/description: now accepts `string
API Types
types/ParseServer.d.ts
Added new static type declaration ParseServer.applyRequestContextMiddleware(api: any, options: any): void.
Tests
spec/index.spec.js
Added tests covering publicServerURL loaded from function and Promise, thrown/rejected function behavior, per-request/per-call execution counting and incremental URL generation, and verification that password reset/verification emails use the latest resolved URL.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Middleware as handleParseHeaders
    participant Config
    participant AppCache
    participant Router as UsersRouter
    participant EmailService

    Client->>Middleware: HTTP request
    Middleware->>Config: validate app config state
    Middleware->>Config: loadKeys()
    Note right of Config `#E6F2FF`: resolve underscored async keys\n(e.g. `_publicServerURL`) per request
    Config->>AppCache: persist updated config if changed
    Middleware->>Middleware: attach resolved config to `req.config`
    Middleware->>Router: forward request
    Router->>EmailService: trigger reset/verify email flow
    EmailService->>Config: read `publicServerURL` or fallback `_publicServerURL`
    EmailService->>Client: send email containing resolved URL
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay special attention to Config.loadKeys() for correct async resolution, concurrency safety, and idempotence.
  • Review transformConfiguration() to ensure it only moves function/Promise keys to underscored properties and preserves other values.
  • Inspect middleware change (handleParseHeaders) for potential race conditions and performance impact.
  • Verify validatePublicServerURL and updated validateEmailConfiguration/UsersRouter fallback properly handle functions that throw or return rejected Promises and respect required semantics.
  • Check AppCache persistence logic to avoid unnecessary writes and ensure correct persisted shape.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description includes a reference to the linked issue (#9798) and indicates tests were added, but lacks detailed explanation of the approach and changes made.
Linked Issues check ✅ Passed Code changes comprehensively implement the feature requirements: publicServerURL now accepts async functions/Promises, is resolved at runtime on each request, maintains backward compatibility with strings, and includes comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are directly related to enabling dynamic async publicServerURL configuration. The new applyRequestContextMiddleware method addition in ParseServer.d.ts appears to support the middleware integration.
Title check ✅ Passed The title accurately describes the main change: enabling publicServerURL to be set dynamically as an asynchronous function, which aligns with the core feature implemented across multiple files.

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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jun 22, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
src/middlewares.js (1)

216-216: Consider performance implications of loading keys on every request.

The await config.loadKeys() call adds async overhead to every request. While the placement is correct (after config retrieval, before usage), consider implementing caching or memoization to avoid repeatedly resolving the same functions on subsequent requests.

Consider adding a cache invalidation strategy or TTL mechanism to avoid unnecessary function calls:

+  // Only load keys if they haven't been loaded or if cache is expired
+  if (!config._keysLoaded || (config._keysLoadedAt && Date.now() - config._keysLoadedAt > config.keysCacheTtl)) {
     await config.loadKeys();
+  }
src/Config.js (2)

35-35: Define asyncKeys as a constant to avoid duplication.

The asyncKeys array is defined here and again in the loadKeys() method (line 61). This duplication could lead to inconsistencies.

Use the constant defined at the top:

  async loadKeys() {
-    const asyncKeys = ['publicServerURL'];
-
     await Promise.all(
       asyncKeys.map(async key => {

74-81: Consider edge cases in transformConfiguration.

The method correctly moves function values to underscored properties, but should validate that the transformation is safe.

Add validation to ensure the transformation doesn't overwrite existing underscored properties:

  static transformConfiguration(serverConfiguration) {
     for (const key of Object.keys(serverConfiguration)) {
       if (asyncKeys.includes(key) && typeof serverConfiguration[key] === 'function') {
+        if (serverConfiguration[`_${key}`]) {
+          throw new Error(`Configuration conflict: both ${key} and _${key} are defined`);
+        }
         serverConfiguration[`_${key}`] = serverConfiguration[key];
         delete serverConfiguration[key];
       }
     }
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d14a723 and 8d4528e.

📒 Files selected for processing (4)
  • spec/index.spec.js (1 hunks)
  • src/Config.js (3 hunks)
  • src/middlewares.js (1 hunks)
  • types/Options/index.d.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Redis Cache
  • GitHub Check: Node 18
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Docker Build
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
🔇 Additional comments (1)
src/Config.js (1)

477-477: ```bash
#!/bin/bash

Search for any loadKeys references across the repository to determine when publicServerURL is resolved

rg -n "loadKeys" -C5 .


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@mtrezza mtrezza changed the title feature: add dynamic publicServerUrl feat: Add dynamic publicServerUrl Jun 22, 2025
@mtrezza mtrezza changed the title feat: Add dynamic publicServerUrl feat: Allow option publicServerURL to be set dynamically as async function Jun 22, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
spec/index.spec.js (2)

629-638: Test title vs. implementation mismatch; add coverage for direct Promise input

The test is named “from Promise” but uses an async function returning a Promise. Since the type allows a direct Promise, add coverage for that input, or adjust this test to match its title.

Option A — keep current behavior, fix title:

-  it('should load publicServerURL from Promise', async () => {
+  it('should load publicServerURL from async function', async () => {

Option B — keep title, pass a direct Promise:

   await reconfigureServer({
-    publicServerURL: () => Promise.resolve('https://async-server.com/1'),
+    publicServerURL: Promise.resolve('https://async-server.com/1'),
   });

Additionally, consider adding a separate test to cover both variants (direct Promise and async function). I can draft the full test block if helpful.


654-665: Add test for direct Promise rejection variant

To fully exercise the accepted input types, also cover when publicServerURL is a rejected Promise directly (not via a function), e.g.:

it('should handle publicServerURL direct Promise rejection', async () => {
  await reconfigureServer({
    publicServerURL: Promise.reject(new Error('Async fetch failed')),
  });
  await expectAsync(new Parse.Object('TestObject').save()).toBeRejected();
});

This complements the current async-function rejection path.

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

618-627: Also assert mount updates when publicServerURL is loaded dynamically

Static config sets config.mount to publicServerURL (see Line 348). To avoid regressions, verify that dynamic resolution updates mount too.

Apply this minimal addition:

     const config = Config.get(Parse.applicationId);
     expect(config.publicServerURL).toEqual('https://myserver.com/1');
+    expect(config.mount).toEqual('https://myserver.com/1');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4e350 and c20b3d0.

📒 Files selected for processing (1)
  • spec/index.spec.js (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
PR: parse-community/parse-server#9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
PR: parse-community/parse-server#9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
PR: parse-community/parse-server#9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • spec/index.spec.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: Docker Build
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Redis Cache
  • GitHub Check: Node 18
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: Code Analysis (javascript)
🔇 Additional comments (1)
spec/index.spec.js (1)

640-653: Error path coverage for throwing function looks good

This correctly triggers key loading via save and asserts rejection using async/await style, consistent with repo test preferences.

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 11, 2025
Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

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

question: Do we expect the function to run on every request? If a developer uses it incorrectly, it could result in massive spam ?

Also, the linked issue mentions a forced restart, but Parse Server has many parameters that don’t support "hot modification". A restart (such as in a containerized environment) is normally expected when environment details change. I’m not sure this kind of feature should actually be implemented.

@mtrezza
Copy link
Member

mtrezza commented Sep 9, 2025

@Moumouls I'll try to answer

Do we expect the function to run on every request? If a developer uses it incorrectly, it could result in massive spam ?

A cache mechanism would be nice, but not required for a first simple implementation of this feature. No noticeable performance impact is expected if the param is set as string (status quo). Most important, it's not a breaking change. If a developer decides to set the param to a function, they need to consider side effects, e.g. delay if async, implement own cache mechanism, etc.

Also, the linked issue mentions a forced restart, but Parse Server has many parameters that don’t support "hot modification". A restart (such as in a containerized environment) is normally expected when environment details change. I’m not sure this kind of feature should actually be implemented.

We are gradually moving to allow changing parse server options without requiring server restart. Started a few years back, we already have options that allow that. Key: no server restart required, #9798 mentions server restart only as alternative.

Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 6, 2025
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 6, 2025
This reverts commit c17632c.
This reverts commit e85245a.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44843e3 and c17632c.

📒 Files selected for processing (5)
  • spec/index.spec.js (1 hunks)
  • src/Config.js (5 hunks)
  • src/Routers/PagesRouter.js (6 hunks)
  • src/Routers/PublicAPIRouter.js (1 hunks)
  • src/batch.js (2 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • src/batch.js
  • src/Routers/PublicAPIRouter.js
  • src/Config.js
  • spec/index.spec.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • src/Routers/PublicAPIRouter.js
  • src/Config.js
  • spec/index.spec.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • src/Routers/PublicAPIRouter.js
  • src/Config.js
  • spec/index.spec.js
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • src/Config.js
  • spec/index.spec.js
📚 Learning: 2025-10-16T19:27:05.311Z
Learnt from: Moumouls
Repo: parse-community/parse-server PR: 9883
File: spec/CloudCodeLogger.spec.js:410-412
Timestamp: 2025-10-16T19:27:05.311Z
Learning: In spec/CloudCodeLogger.spec.js, the test "should log cloud function triggers using the silent log level" (around lines 383-420) is known to be flaky and requires the extra `await new Promise(resolve => setTimeout(resolve, 100))` timeout after awaiting `afterSavePromise` for reliability, even though it may appear redundant.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-04-30T19:31:35.344Z
Learnt from: RahulLanjewar93
Repo: parse-community/parse-server PR: 9744
File: spec/ParseLiveQuery.spec.js:0-0
Timestamp: 2025-04-30T19:31:35.344Z
Learning: In the Parse Server codebase, the functions in QueryTools.js are typically tested through end-to-end behavior tests rather than direct unit tests, even though the functions are exported from the module.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-08-27T12:33:06.237Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:467-477
Timestamp: 2025-08-27T12:33:06.237Z
Learning: In the Parse Server codebase, maybeRunAfterFindTrigger is called in production with Parse.Query objects constructed via withJSON(), so the plain object query handling bug only affects tests, not production code paths.

Applied to files:

  • spec/index.spec.js
🧬 Code graph analysis (5)
src/batch.js (1)
spec/batch.spec.js (1)
  • publicServerURL (8-8)
src/Routers/PublicAPIRouter.js (2)
src/Config.js (1)
  • Config (54-807)
src/batch.js (1)
  • publicServerURL (80-80)
src/Config.js (2)
src/middlewares.js (3)
  • config (207-207)
  • config (643-643)
  • config (645-645)
src/batch.js (1)
  • publicServerURL (80-80)
spec/index.spec.js (2)
spec/helper.js (2)
  • reconfigureServer (180-214)
  • Parse (4-4)
src/Config.js (1)
  • Config (54-807)
src/Routers/PagesRouter.js (2)
src/middlewares.js (3)
  • config (207-207)
  • config (643-643)
  • config (645-645)
src/batch.js (1)
  • publicServerURL (80-80)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Node 20
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: Node 22
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: Node 18
  • GitHub Check: Redis Cache
  • GitHub Check: Docker Build

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
src/Config.js (2)

143-151: Update validation to handle Promise type and improve error message.

The validation has two issues:

  1. Doesn't account for publicServerURL being a direct Promise<string> (allowed by the type definition)
  2. The error message is misleading - it doesn't mention that functions and Promises are valid inputs

Apply this diff to fix validation:

    if (publicServerURL) {
      if (
        typeof publicServerURL !== 'function' &&
+       !(publicServerURL instanceof Promise) &&
        !publicServerURL.startsWith('http://') &&
        !publicServerURL.startsWith('https://')
      ) {
-       throw 'publicServerURL should be a valid HTTPS URL starting with https://';
+       throw 'publicServerURL should be a valid HTTPS URL starting with https://, a function returning a URL, or a Promise resolving to a URL';
      }
    }

60-72: Add error handling, Promise support, and value validation.

The method has several issues:

  1. No error handling if functions throw or return invalid values
  2. Only handles functions returning Promises, not direct Promise values (inconsistent with the type definition that allows Promise<string>)
  3. No validation of resolved values (e.g., ensuring publicServerURL is a valid URL)
  4. Calling AppCache.put(this) on every invocation may be expensive

Apply this diff to add comprehensive error handling and Promise support:

  async loadKeys() {
    const asyncKeys = ['publicServerURL'];

    await Promise.all(
      asyncKeys.map(async key => {
+       try {
+         // Handle both functions and direct Promises
          if (typeof this[`_${key}`] === 'function') {
            this[key] = await this[`_${key}`]();
+         } else if (this[`_${key}`] instanceof Promise) {
+           this[key] = await this[`_${key}`];
          }
+         
+         // Validate the resolved value for publicServerURL
+         if (key === 'publicServerURL' && this[key]) {
+           if (typeof this[key] !== 'string') {
+             throw new Error('publicServerURL must resolve to a string');
+           }
+           if (!this[key].startsWith('http://') && !this[key].startsWith('https://')) {
+             throw new Error('publicServerURL must be a valid HTTP/HTTPS URL');
+           }
+         }
+       } catch (error) {
+         throw new Error(`Failed to load ${key}: ${error.message}`);
+       }
      })
    );

    AppCache.put(this.appId, this);
  }
🧹 Nitpick comments (1)
src/Config.js (1)

35-35: Remove duplicate asyncKeys declaration.

The asyncKeys array is declared here at the module level but then redeclared as a local variable in loadKeys() at line 61. This module-level declaration is unused and should be removed to avoid confusion.

Apply this diff:

-const asyncKeys = ['publicServerURL'];
 export class Config {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c17632c and b76bbf4.

📒 Files selected for processing (2)
  • spec/index.spec.js (1 hunks)
  • src/Config.js (3 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • spec/index.spec.js
  • src/Config.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • spec/index.spec.js
  • src/Config.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • spec/index.spec.js
  • src/Config.js
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • spec/index.spec.js
  • src/Config.js
📚 Learning: 2025-10-16T19:27:05.311Z
Learnt from: Moumouls
Repo: parse-community/parse-server PR: 9883
File: spec/CloudCodeLogger.spec.js:410-412
Timestamp: 2025-10-16T19:27:05.311Z
Learning: In spec/CloudCodeLogger.spec.js, the test "should log cloud function triggers using the silent log level" (around lines 383-420) is known to be flaky and requires the extra `await new Promise(resolve => setTimeout(resolve, 100))` timeout after awaiting `afterSavePromise` for reliability, even though it may appear redundant.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-04-30T19:31:35.344Z
Learnt from: RahulLanjewar93
Repo: parse-community/parse-server PR: 9744
File: spec/ParseLiveQuery.spec.js:0-0
Timestamp: 2025-04-30T19:31:35.344Z
Learning: In the Parse Server codebase, the functions in QueryTools.js are typically tested through end-to-end behavior tests rather than direct unit tests, even though the functions are exported from the module.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-08-27T12:33:06.237Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:467-477
Timestamp: 2025-08-27T12:33:06.237Z
Learning: In the Parse Server codebase, maybeRunAfterFindTrigger is called in production with Parse.Query objects constructed via withJSON(), so the plain object query handling bug only affects tests, not production code paths.

Applied to files:

  • spec/index.spec.js
🧬 Code graph analysis (1)
spec/index.spec.js (2)
spec/helper.js (2)
  • reconfigureServer (180-214)
  • Parse (4-4)
src/Config.js (1)
  • Config (36-796)
🔇 Additional comments (2)
spec/index.spec.js (1)

689-854: Comprehensive test coverage looks good.

The test suite thoroughly covers the new publicServerURL functionality including:

  • Basic function and Promise support
  • Error handling for both synchronous throws and Promise rejections
  • Per-access function invocation with the counter pattern
  • Dynamic URL behavior in password reset and verification emails

All tests follow the repository's async/await patterns without callback-based done().

Note: The fdescribe at line 689 was already flagged and marked as addressed in previous review comments.

Based on learnings.

src/Config.js (1)

74-81: Transformation logic is correct.

The transformConfiguration method properly moves function-valued async keys to underscored properties (e.g., publicServerURL_publicServerURL), which enables the lazy evaluation pattern in loadKeys(). This design allows the function to be preserved in the cached config for repeated execution at request time.

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.06%. Comparing base (9776386) to head (b508a3a).
⚠️ Report is 6 commits behind head on alpha.

Files with missing lines Patch % Lines
src/Config.js 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9803      +/-   ##
==========================================
+ Coverage   93.04%   93.06%   +0.01%     
==========================================
  Files         187      187              
  Lines       15160    15187      +27     
  Branches      177      177              
==========================================
+ Hits        14106    14134      +28     
+ Misses       1042     1041       -1     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7dabfaf and 2506eda.

📒 Files selected for processing (1)
  • src/Config.js (7 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • src/Config.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Redis Cache
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Node 18
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 22
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: Node 20
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Docker Build

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

712-736: Consider verifying specific error details.

While these tests correctly verify that operations are rejected when publicServerURL resolution fails, they don't assert the specific error message or type. This could make debugging harder if the wrong error is thrown.

Consider updating the tests to verify error details:

     it('should handle publicServerURL function throwing error', async () => {
       const errorMessage = 'Failed to get public server URL';
       await reconfigureServer({
         publicServerURL: () => {
           throw new Error(errorMessage);
         },
       });
 
-      // The error should occur when trying to save an object (which triggers loadKeys in middleware)
-      await expectAsync(
-        new Parse.Object('TestObject').save()
-      ).toBeRejected();
+      const error = await new Parse.Object('TestObject').save().catch(e => e);
+      expect(error.message).toContain(errorMessage);
     });

Apply similar changes to the Promise rejection test to verify the error message.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2506eda and b010721.

📒 Files selected for processing (1)
  • spec/index.spec.js (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-10-16T19:27:05.311Z
Learnt from: Moumouls
Repo: parse-community/parse-server PR: 9883
File: spec/CloudCodeLogger.spec.js:410-412
Timestamp: 2025-10-16T19:27:05.311Z
Learning: In spec/CloudCodeLogger.spec.js, the test "should log cloud function triggers using the silent log level" (around lines 383-420) is known to be flaky and requires the extra `await new Promise(resolve => setTimeout(resolve, 100))` timeout after awaiting `afterSavePromise` for reliability, even though it may appear redundant.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-04-30T19:31:35.344Z
Learnt from: RahulLanjewar93
Repo: parse-community/parse-server PR: 9744
File: spec/ParseLiveQuery.spec.js:0-0
Timestamp: 2025-04-30T19:31:35.344Z
Learning: In the Parse Server codebase, the functions in QueryTools.js are typically tested through end-to-end behavior tests rather than direct unit tests, even though the functions are exported from the module.

Applied to files:

  • spec/index.spec.js
📚 Learning: 2025-08-27T12:33:06.237Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:467-477
Timestamp: 2025-08-27T12:33:06.237Z
Learning: In the Parse Server codebase, maybeRunAfterFindTrigger is called in production with Parse.Query objects constructed via withJSON(), so the plain object query handling bug only affects tests, not production code paths.

Applied to files:

  • spec/index.spec.js
🧬 Code graph analysis (1)
spec/index.spec.js (2)
spec/helper.js (3)
  • reconfigureServer (180-214)
  • Parse (4-4)
  • user (296-296)
src/Config.js (1)
  • Config (36-811)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Redis Cache
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 18
  • GitHub Check: Node 22
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Docker Build
🔇 Additional comments (6)
spec/index.spec.js (6)

366-366: LGTM!

The updated error message accurately reflects the new validation requirements for publicServerURL and provides clear guidance to users.


690-699: LGTM!

This test properly verifies that publicServerURL can be provided as a function and is correctly resolved when accessed.


701-710: LGTM!

This test correctly verifies Promise-based publicServerURL resolution, addressing the comprehensive coverage requested in past reviews.


738-764: Excellent test for per-request execution!

This test effectively verifies that the publicServerURL function is executed on every request rather than being cached, using a counter to prove dynamic resolution. This addresses the critical requirement that the URL can change at runtime without server restart.


766-808: LGTM! Strong integration test.

This test effectively verifies that password reset emails use the dynamically resolved publicServerURL on each request. The counter pattern demonstrates that each email can receive a different URL without server restart, which is the key use case for this feature.


810-853: LGTM! Comprehensive email integration coverage.

This test completes the email integration coverage by verifying verification emails also use the dynamically resolved publicServerURL. Together with the password reset test, this demonstrates that the feature works correctly across different email scenarios.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/Config.js (2)

182-201: Consider documenting the _publicServerURL fallback logic.

The fallback publicServerURL || _publicServerURL at line 196 is subtle: when publicServerURL is a function, transformConfiguration() has moved it to _publicServerURL and deleted the original. The fallback ensures email validation receives either the string or the function.

Consider adding a brief comment to clarify this for future maintainers:

   static validateControllers({
     verifyUserEmails,
     userController,
     appName,
     publicServerURL,
     _publicServerURL,
     emailVerifyTokenValidityDuration,
     emailVerifyTokenReuseIfValid,
   }) {
     const emailAdapter = userController.adapter;
     if (verifyUserEmails) {
       this.validateEmailConfiguration({
         emailAdapter,
         appName,
+        // If publicServerURL is a function, it's been moved to _publicServerURL by transformConfiguration
         publicServerURL: publicServerURL || _publicServerURL,
         emailVerifyTokenValidityDuration,
         emailVerifyTokenReuseIfValid,
       });
     }
   }

466-488: Document expected function signature and reference Promise support issue.

The validation accepts a function but doesn't document the expected signature. Developers need to know the function should return a string URL (or Promise<string> once Promise support is added).

Consider adding JSDoc to document the expected types:

+  /**
+   * Validates the publicServerURL configuration option.
+   * @param {Object} options - Validation options
+   * @param {string|function():string|Promise<string>} options.publicServerURL - The public server URL or function that returns it
+   * @param {boolean} [options.required=false] - Whether the option is required
+   * @throws {string} If validation fails
+   */
   static validatePublicServerURL({ publicServerURL, required = false }) {

Note: There's an existing issue (flagged in past review) that the validation doesn't handle Promise<string> despite it being mentioned in type definitions. This should be addressed separately.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b010721 and 7f759c8.

📒 Files selected for processing (1)
  • src/Config.js (7 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • src/Config.js
🔇 Additional comments (3)
src/Config.js (3)

35-38: Good approach for extensibility.

The asyncKeys constant provides a clear, centralized list of configuration options that support async resolution. This makes it easy to add more dynamic options in the future.


83-90: Clean separation of function definition from resolved value.

The transformation correctly moves async function-based config values to underscored properties, enabling lazy evaluation at request time while preserving the function for repeated execution.


490-517: Good refactoring with correct required flag.

The change to use the centralized validatePublicServerURL() helper with required: true is appropriate here, as email verification functionality cannot work without a valid public server URL.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f759c8 and d3d6e2b.

📒 Files selected for processing (3)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Options/docs.js
🧰 Additional context used
🪛 Biome (2.1.2)
src/Options/index.js

[error] 229-229: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Redis Cache
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Node 18
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: Node 20
  • GitHub Check: Node 22
  • GitHub Check: Docker Build
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: MongoDB 8, ReplicaSet
🔇 Additional comments (1)
src/Options/Definitions.js (1)

496-500: LGTM!

The help text has been correctly updated to document the new async function capability. Since this is a generated file (as noted in the header), the change appropriately reflects the documentation update in src/Options/index.js.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
types/ParseServer.d.ts (1)

29-33: Consider replacing any types with Express.Application and ParseServerOptions.

The implementation is correctly implemented and matches the type definition. However, the any types can be improved for better type safety:

  • api parameter should be Express.Application (requires adding import * as express from 'express' or appropriate Express type import)
  • options parameter should be ParseServerOptions (already imported in the file)

This change would provide developers with proper IDE autocomplete and catch type errors at compile time.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3d6e2b and 3511605.

📒 Files selected for processing (5)
  • src/Config.js (7 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • types/Options/index.d.ts (1 hunks)
  • types/ParseServer.d.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-08-27T09:08:34.252Z
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Applied to files:

  • src/Options/index.js
  • src/Config.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • src/Config.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • src/Config.js
📚 Learning: 2025-10-16T19:27:05.311Z
Learnt from: Moumouls
Repo: parse-community/parse-server PR: 9883
File: spec/CloudCodeLogger.spec.js:410-412
Timestamp: 2025-10-16T19:27:05.311Z
Learning: In spec/CloudCodeLogger.spec.js, the test "should log cloud function triggers using the silent log level" (around lines 383-420) is known to be flaky and requires the extra `await new Promise(resolve => setTimeout(resolve, 100))` timeout after awaiting `afterSavePromise` for reliability, even though it may appear redundant.

Applied to files:

  • src/Config.js
🪛 Biome (2.1.2)
src/Options/index.js

[error] 229-229: Expected a statement but instead found '?'.

Expected a statement here.

(parse)


[error] 231-231: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

🔇 Additional comments (10)
types/Options/index.d.ts (1)

88-88: LGTM! Type definition aligns with implementation.

The updated type correctly represents all supported forms of publicServerURL (string, sync function, or async function), matching the implementation in src/Config.js where loadKeys() resolves functions via await this[_${key}]().

src/Options/index.js (1)

229-231: LGTM! Flow type definition is consistent across the codebase.

The updated Flow type correctly matches the TypeScript definition and implementation, supporting string, sync function, or async function forms. The expanded comment clearly describes the behavior.

Note: The Biome static analysis errors on lines 229 and 231 are false positives caused by Flow's nullable ? syntax, which Biome misinterprets.

src/Config.js (7)

35-38: LGTM! Clean and extensible design.

The asyncKeys array provides a clear, centralized list of configuration keys that need async resolution, making it easy to extend for future async options.


64-85: LGTM! Robust async key resolution with proper error handling.

The implementation correctly:

  • Resolves all async keys concurrently via Promise.all
  • Wraps resolution in try-catch with descriptive error messages
  • Updates AppCache with resolved values to persist changes
  • Maintains existing cache structure

87-94: LGTM! Transformation correctly separates function definitions from resolved values.

The method properly moves function-based configuration values to underscored properties (e.g., _publicServerURL), enabling:

  • Function preservation in the cache for repeated evaluation
  • Clean separation: _publicServerURL stores the function, publicServerURL stores the resolved string
  • Lazy evaluation at request time via loadKeys()

470-492: LGTM! Comprehensive validation with clear error messages.

The centralized validation correctly handles:

  • Optional vs required scenarios
  • String validation (URL format with http/https protocol)
  • Function acceptance (deferred validation until invocation)
  • Clear error messages indicating expected types and actual type received

156-156: LGTM! Proper use of centralized validation.

The refactoring to use validatePublicServerURL() improves maintainability by centralizing validation logic. The optional nature (no required parameter) is correct for general configuration validation.


186-204: LGTM! Correct fallback logic for async key handling.

The addition of _publicServerURL parameter and fallback logic (publicServerURL || _publicServerURL) is essential for email verification features to work correctly when publicServerURL is provided as a function. After transformConfiguration(), the function is stored in _publicServerURL, so this fallback ensures it's available for validation.


494-507: LGTM! Email configuration validation correctly enforces required URL.

The use of validatePublicServerURL({ publicServerURL, required: true }) is appropriate since email verification and password reset features depend on a valid public URL. The validation will accept either a string URL or a function that resolves to a URL.

src/Options/docs.js (1)

90-90: LGTM! Documentation accurately reflects the new behavior.

The JSDoc update correctly:

  • Changes type to Union to represent multiple supported forms
  • Describes that the option can be a string or asynchronously resolved function
  • Documents the URL format requirement (http:// or https://)
  • Mentions key use cases (password reset, email verification)

This aligns with the implementation in src/Config.js and type definitions across the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 7, 2025
@mtrezza mtrezza changed the title feat: Allow option publicServerURL to be set dynamically as async function feat: Allow option publicServerURL to be set dynamically as asynchronous function Nov 7, 2025
@mtrezza
Copy link
Member

mtrezza commented Nov 7, 2025

@coderabbitai review the PR again after the latest commit

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

@mtrezza: I'll review the PR again with the latest changes.


🧠 Learnings used
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:446-454
Timestamp: 2025-08-27T09:08:34.252Z
Learning: When analyzing function signature changes in Parse Server codebase, verify that call sites are actually incorrect before flagging them. Passing tests are a strong indicator that function calls are already properly aligned with new signatures.

Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: src/triggers.js:467-477
Timestamp: 2025-08-27T12:33:06.237Z
Learning: In the Parse Server codebase, maybeRunAfterFindTrigger is called in production with Parse.Query objects constructed via withJSON(), so the plain object query handling bug only affects tests, not production code paths.
✅ 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.

@mtrezza mtrezza merged commit 460a65c into parse-community:alpha Nov 7, 2025
25 of 27 checks passed
parseplatformorg pushed a commit that referenced this pull request Nov 7, 2025
# [8.5.0-alpha.1](8.4.0...8.5.0-alpha.1) (2025-11-07)

### Features

* Allow option `publicServerURL` to be set dynamically as asynchronous function ([#9803](#9803)) ([460a65c](460a65c))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.5.0-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow option publicServerURL to be set dynamically as async function

4 participants