fix: No IP address in request when directAccess is enabled#10542
fix: No IP address in request when directAccess is enabled#10542dblythy wants to merge 1 commit into
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
📝 WalkthroughWalkthroughAdds a ChangesLoopback IP defaulting
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ParseServerRESTController
participant os
participant CloudTrigger
Client->>ParseServerRESTController: handleRequest()
ParseServerRESTController->>ParseServerRESTController: load config
alt config.ip not set
ParseServerRESTController->>os: networkInterfaces()
os-->>ParseServerRESTController: interface list
ParseServerRESTController->>ParseServerRESTController: getLoopbackAddress() returns ::1 or 127.0.0.1
ParseServerRESTController->>ParseServerRESTController: set config.ip
end
ParseServerRESTController->>CloudTrigger: invoke beforeSave with req.ip set
CloudTrigger-->>Client: response
Related Issues: Suggested labels: bug, low-risk Suggested reviewers: parse-community maintainers 🐰✨
🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10542 +/- ##
=======================================
Coverage 92.66% 92.67%
=======================================
Files 193 193
Lines 16981 16990 +9
Branches 248 248
=======================================
+ Hits 15736 15745 +9
Misses 1224 1224
Partials 21 21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/ParseServerRESTController.js (1)
5-18: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider guarding
os.networkInterfaces()against failure.If this call throws (e.g., in a sandboxed/restricted runtime with limited OS permissions),
loopbackAddressnever gets cached, so every subsequenthandleRequestcall without a presetconfig.ipwill re-throw synchronously, breaking all direct-access requests in that environment persistently (not just once).🛡️ Suggested defensive fallback
function getLoopbackAddress() { if (loopbackAddress) { return loopbackAddress; } - const interfaces = os.networkInterfaces(); - const hasIPv6Loopback = Object.values(interfaces).some(addresses => - addresses?.some(iface => iface.internal && (iface.family === 'IPv6' || iface.family === 6)) - ); - loopbackAddress = hasIPv6Loopback ? '::1' : '127.0.0.1'; + let hasIPv6Loopback = false; + try { + const interfaces = os.networkInterfaces(); + hasIPv6Loopback = Object.values(interfaces).some(addresses => + addresses?.some(iface => iface.internal && (iface.family === 'IPv6' || iface.family === 6)) + ); + } catch (e) { + // Fall back to IPv4 loopback if interfaces cannot be enumerated. + } + loopbackAddress = hasIPv6Loopback ? '::1' : '127.0.0.1'; return loopbackAddress; }🤖 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 `@src/ParseServerRESTController.js` around lines 5 - 18, The getLoopbackAddress helper currently assumes os.networkInterfaces() always succeeds, so a throw leaves loopbackAddress unset and causes repeated synchronous failures on every handleRequest path that relies on the default address. Update getLoopbackAddress to defensively catch failures around os.networkInterfaces(), then cache a safe fallback value (for example the IPv4 loopback) so subsequent calls do not keep re-throwing; keep the logic contained in getLoopbackAddress and preserve the existing loopbackAddress memoization behavior.
🤖 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 `@src/ParseServerRESTController.js`:
- Around line 5-18: The getLoopbackAddress helper currently assumes
os.networkInterfaces() always succeeds, so a throw leaves loopbackAddress unset
and causes repeated synchronous failures on every handleRequest path that relies
on the default address. Update getLoopbackAddress to defensively catch failures
around os.networkInterfaces(), then cache a safe fallback value (for example the
IPv4 loopback) so subsequent calls do not keep re-throwing; keep the logic
contained in getLoopbackAddress and preserve the existing loopbackAddress
memoization behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 10851333-d9b3-4ebd-9cf9-2e377c70b05d
📒 Files selected for processing (2)
spec/ParseServerRESTController.spec.jssrc/ParseServerRESTController.js
Closes #8806
Summary by CodeRabbit
Bug Fixes
127.0.0.1or::1) depending on the environment.Tests