Skip to content

Conversation

@modime
Copy link
Contributor

@modime modime commented Oct 27, 2025

Pull Request

Issue

Closes: #2773

Relates to: #2622

Approach

This Pull Request puts back a line of code that existed in Cloud.ts in v5.3.0 but was removed in v6.0.0.

This removal added a breaking change of the code with different behaviour when the options parameter was null.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

Summary by CodeRabbit

  • Bug Fixes
    • Cloud.run now tolerates undefined, null, or empty options without causing errors, improving stability when callers omit options. Tests updated to cover these cases.

Marcus Olsson added 2 commits October 27, 2025 18:01
Guarantees that the options object is initialized to prevent potential errors when calling cloud functions. This ensures smooth execution even when no options are explicitly provided.
Updates the validation logic for the options parameter in the Cloud.run function.

Allows null as a valid options value, and removes null from the invalid options list.
This change ensures the function correctly handles different input scenarios.
@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 27, 2025

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Oct 27, 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.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

📝 Walkthrough

Walkthrough

Normalize falsy options in Cloud.run() by defaulting it to an empty object when undefined or null; update tests to treat undefined, null, and {} as valid option inputs and to adjust invalid-case expectations.

Changes

Cohort / File(s) Summary
Core implementation
src/Cloud.ts
Add defensive defaulting: `options = options
Test updates
src/__tests__/Cloud-test.js
Broaden valid-options test cases from [undefined, {}] to [undefined, null, {}]; narrow invalid-options cases to [[]]; update test names to reflect new coverage.

Sequence Diagram(s)

sequenceDiagram
  participant C as Caller
  participant SDK as Parse SDK (Cloud.run)
  participant S as Server

  C->>SDK: Cloud.run(name, data, options)
  rect rgb(235,245,255)
    SDK->>SDK: normalize options\n(options = options || {})
    SDK-->>SDK: validate options type
  end
  alt options valid
    SDK->>S: send request (name, data, options)
    S-->>SDK: response
    SDK-->>C: resolve/return response
  else options invalid
    SDK-->>C: throw TypeError (before network)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Small defensive change in one core file and corresponding test adjustments.
  • Pay attention to:
    • src/Cloud.ts — ensure the defaulting is applied before any property access or validation.
    • src/__tests__/Cloud-test.js — confirm tests accurately reflect intended valid/invalid inputs (undefined, null, {} valid; arrays invalid).

Suggested reviewers

  • mtrezza
  • kinetifex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed The pull request directly addresses the core requirement from issue #2773 to restore the default value handling for the options parameter in Parse.Cloud.run. The code change in src/Cloud.ts implements "options = options || {}" to treat null/missing options as an empty object, which allows requests with null options to reach the server instead of throwing a TypeError, matching the expected behavior described in the issue. The corresponding test updates in src/tests/Cloud-test.js validate that undefined, null, and empty options are now treated as valid input cases.
Out of Scope Changes Check ✅ Passed All code changes in the pull request are directly in-scope with the linked issue requirements. The modification to src/Cloud.ts adds the default value handling for the options parameter, which directly restores the v5.3.0 behavior described in issue #2773. The test changes in src/tests/Cloud-test.js are also in-scope as they validate the restored behavior by testing that null and undefined options are handled correctly. No extraneous or unrelated changes are present.
Title Check ✅ Passed The PR title "fix: Sets default value for missing options parameter" is directly related to the main change in the changeset. The raw_summary confirms that the primary modification in src/Cloud.ts adds options = options || {} to default the options parameter when it's falsy, which is exactly what the title describes. The title is specific and clear, indicating both that this is a bug fix and what is being fixed, rather than being vague or generic. The updated tests in src/tests/Cloud-test.js further support this central objective by broadening the valid option cases to include null as a default-equivalent value. The title accurately reflects the core intent of restoring previously removed behavior from v5.3.0.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@modime modime changed the title Fix: sets default value for missing options parameter fix: sets default value for missing options parameter Oct 27, 2025
@parse-github-assistant
Copy link

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

@parse-github-assistant parse-github-assistant bot changed the title fix: sets default value for missing options parameter fix: Sets default value for missing options parameter Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (492de3e) to head (77486bb).
⚠️ Report is 4 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #2774   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files          64       64           
  Lines        6220     6221    +1     
  Branches     1476     1477    +1     
=======================================
+ Hits         6213     6214    +1     
  Misses          7        7           

☔ 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 7cc7a16 and 825ee1a.

📒 Files selected for processing (2)
  • src/Cloud.ts (1 hunks)
  • src/__tests__/Cloud-test.js (2 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint
src/Cloud.ts

[failure] 49-49:
Trailing spaces not allowed

⏰ 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). (3)
  • GitHub Check: build (Node 20, 20.15.1)
  • GitHub Check: build (Node 22, 22.4.1)
  • GitHub Check: build (Node 18, 18.20.4)
🔇 Additional comments (2)
src/__tests__/Cloud-test.js (2)

360-377: LGTM! Test correctly validates the defaulting behavior.

The test now properly verifies that undefined, null, and {} are all treated equivalently as valid options, aligning with the production code change.


379-384: LGTM! Invalid options test correctly narrowed.

Now that null is handled as a valid option (defaulted to {}), the test correctly identifies only non-object types like arrays as invalid.

Removed trailing space

Signed-off-by: Marcus Olsson <[email protected]>
@modime modime changed the title fix: Sets default value for missing options parameter fix: sets default value for missing options parameter Oct 27, 2025
@parse-github-assistant
Copy link

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

@parse-github-assistant parse-github-assistant bot changed the title fix: sets default value for missing options parameter fix: Sets default value for missing options parameter Oct 27, 2025
@mtrezza
Copy link
Member

mtrezza commented Oct 29, 2025

Closing as #2773 was also closed.

@mtrezza mtrezza closed this Oct 29, 2025
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.

Default value for options in Parse.Cloud.run is no longer set

3 participants