-
-
Notifications
You must be signed in to change notification settings - Fork 600
fix: Sets default value for missing options parameter #2774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
🚀 Thanks for opening this pull request! |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughNormalize falsy Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
I will reformat the title to use the proper commit message syntax. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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
📒 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
nullis 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]>
|
I will reformat the title to use the proper commit message syntax. |
|
Closing as #2773 was also closed. |
Pull Request
Issue
Closes: #2773
Relates to: #2622
Approach
This Pull Request puts back a line of code that existed in
Cloud.tsin 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
Summary by CodeRabbit