fix: clear inherited DNS lookup for non-localhost URLs in redirect handling - #7426
Conversation
|
No actionable comments were generated in the recent review. ð âđïļ Recent review infoâïļ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ð Files selected for processing (2)
ð§ Files skipped from review as they are similar to previous changes (2)
WalkthroughRemoves any preexisting Changes
Sequence Diagram(s)(No sequence diagram generated.) Estimated code review effortðŊ 3 (Moderate) | âąïļ ~20 minutes Suggested labels
Suggested reviewers
Poem
ðĨ Pre-merge checks | â 4 | â 1â Failed checks (1 warning)
â Passed checks (4 passed)
âïļ Tip: You can configure your own custom pre-merge checks in the settings. âĻ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ðĪ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/bruno-electron/tests/network/axios-instance.spec.js`:
- Around line 39-43: The tests currently reach into axios internals by grabbing
axiosInstance.interceptors.request.handlers[0] and calling .fulfilled, which
couples tests to implementation; instead, refactor tests for makeAxiosInstance
to exercise the public request flow by installing a stub adapter on
axiosInstance (or using axios-mock-adapter) and sending a real request through
axiosInstance(), then assert that response.config.lookup (or the mutated config)
is set as expected. Replace references to requestInterceptor usage with a
request call like axiosInstance({ url: '/', adapter: stubAdapter }) and verify
response.config.lookup, keeping the assertions behavior-driven and avoiding
direct access to interceptors.request.handlers.
âđïļ Review info
âïļ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 72315f18-8112-4429-b951-fbab5e957f2c
ð Files selected for processing (2)
packages/bruno-electron/src/ipc/network/axios-instance.jspackages/bruno-electron/tests/network/axios-instance.spec.js
sanish-bruno
left a comment
There was a problem hiding this comment.
PR Review
Found 1 issue(s): 0 major, 0 minor, 1 nit.
Summary
- The 2-line fix is correct and minimal â
delete config.lookupin theelsebranch of the request interceptor properly clears the inherited DNS lookup function for non-localhost URLs during redirects. - The redirect flow is sound: config spread at L347 inherits
lookup, theninstance(requestConfig)at L439 re-enters the request interceptor where theelseclause now cleans it up. - Tests are well-structured using a stub adapter pattern that exercises the public request flow without poking at axios internals. Good coverage of localhost variants, external domains, and the redirect inheritance scenario.
deleteon a non-existent property is a safe no-op, so first-time non-localhost requests are unaffected.
âĶndling When redirecting from localhost to an external domain, the custom DNS lookup function (which always resolves to 127.0.0.1 or ::1) was being inherited via config spread. This caused external domains to incorrectly resolve to localhost, resulting in ECONNREFUSED errors. The fix adds an else clause to the request interceptor that clears any inherited lookup function for non-localhost URLs, ensuring external domains use normal DNS resolution. Fixes usebruno#7343
Replace direct access to axios interceptor internals with a behavior-driven approach using a stub adapter. Tests now exercise the public request flow by making actual requests through axiosInstance() and asserting on the config that reaches the adapter. This decouples tests from axios implementation details and makes them more maintainable.
âĶredirect Renamed test and added an inherited lookup function to properly simulate a redirect scenario, verifying the interceptor replaces it with a fresh one.
3661535 to
6a32316
Compare
The merge-base changed after approval.
Description
JIRA
When redirecting from localhost to an external domain, the custom DNS lookup function (which always resolves to 127.0.0.1 or ::1) was being inherited via config spread. This caused external domains to incorrectly resolve to localhost, resulting in ECONNREFUSED errors.
The fix adds an else clause to the request interceptor that clears any inherited lookup function for non-localhost URLs, ensuring external domains use normal DNS resolution.
Fixes #7343
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
Tests