Skip to content

fix: handle missing location header in redirect error response - #7725

Merged
sid-bruno merged 1 commit into
usebruno:mainfrom
Pragadesh-45:fix/display-timeline-for-302-with-no-location-header
Jul 9, 2026
Merged

sid-bruno merged 1 commit into
usebruno:mainfrom
Pragadesh-45:fix/display-timeline-for-302-with-no-location-header

Conversation

@Pragadesh-45

@Pragadesh-45 Pragadesh-45 commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

BRU
fixes: #5880

Description

  • Added a check for the presence of the location header in the error response during redirect handling. If the header is absent, the error response is augmented with the timeline and the promise is rejected accordingly.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced error handling for HTTP redirect responses that are missing required headers, ensuring more reliable and graceful handling of network requests in edge cases.

- Added a check for the presence of the location header in the error response during redirect handling. If the header is absent, the error response is augmented with the timeline and the promise is rejected accordingly.
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

A guard was added to the redirect-handling logic in the axios instance to prevent processing invalid redirects. When a redirect response lacks a Location header, the error is now immediately rejected with timeline context attached, preventing undefined URL errors.

Changes

Cohort / File(s) Summary
Redirect validation guard
packages/bruno-electron/src/ipc/network/axios-instance.js
Added early-return validation for redirect responses missing the Location header, attaching timeline context before rejecting the error.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • PR #7426 — Modifies redirect-handling behavior in the same file, addressing non-localhost redirect DNS lookup concerns.

Suggested labels

size/L

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • naman-bruno

Poem

🔗 A redirect without a location's call,
Led to errors that vexed one and all,
Now guards stand tall, catching the flaw,
With timeline in hand—no more "url" saw! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds a guard for missing Location headers in redirect responses, which addresses the root cause of the reported URL error by preventing undefined redirect URLs.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to redirect error handling with missing location headers, directly addressing the linked issue #5880.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding guard logic to handle missing Location headers in redirect error responses.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/network/axios-instance.js (1)

330-333: Add explicit error context when rejecting missing-Location redirects.

The guard is correct and prevents the undefined URL path, but it currently rejects without recording why redirect handling stopped. Add a timeline error entry here for clearer diagnostics.

Suggested patch
           if (!locationHeader) {
+            timeline.push({
+              timestamp: new Date(),
+              type: 'error',
+              message: 'Redirect response missing Location header; aborting redirect handling'
+            });
             error.response.timeline = timeline;
             return Promise.reject(error);
           }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/ipc/network/axios-instance.js` around lines 330 -
333, When the redirect guard sees a missing locationHeader and rejects, add an
explicit timeline entry to error.response.timeline describing why redirect
handling stopped; for example, before the Promise.reject(error) call push a
descriptive entry (e.g., "redirect_missing_location" with a message and any
useful context like response.status or headers) into error.response.timeline so
diagnostics record the reason; update the block that references locationHeader,
error.response.timeline, and Promise.reject(error) to insert that timeline entry
prior to rejecting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bruno-electron/src/ipc/network/axios-instance.js`:
- Around line 330-333: When the redirect guard sees a missing locationHeader and
rejects, add an explicit timeline entry to error.response.timeline describing
why redirect handling stopped; for example, before the Promise.reject(error)
call push a descriptive entry (e.g., "redirect_missing_location" with a message
and any useful context like response.status or headers) into
error.response.timeline so diagnostics record the reason; update the block that
references locationHeader, error.response.timeline, and Promise.reject(error) to
insert that timeline entry prior to rejecting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 70b8a60e-3220-4b2f-a55d-9f6a7c7858fa

📥 Commits

Reviewing files that changed from the base of the PR and between cd06f28 and 7d6371a.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/network/axios-instance.js

@Pragadesh-45 Pragadesh-45 changed the title fix: handle missing location header in redirect error response #bsq -- fix: handle missing location header in redirect error response Apr 10, 2026
@Pragadesh44-Bruno Pragadesh44-Bruno self-assigned this Apr 28, 2026
@Pragadesh44-Bruno Pragadesh44-Bruno changed the title #bsq -- fix: handle missing location header in redirect error response fix: handle missing location header in redirect error response Apr 28, 2026

@prateek-bruno prateek-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked locally, LGTM!

@prateek-bruno prateek-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be good to have tests to validate this behaviour.

@sid-bruno
sid-bruno merged commit d4b8860 into usebruno:main Jul 9, 2026
10 checks passed
ravindra-bruno pushed a commit to ravindra-bruno/bruno that referenced this pull request Jul 9, 2026
sid-bruno added a commit to sid-bruno/bruno that referenced this pull request Aug 21, 2026
* fix: handle missing location header in redirect error response (usebruno#7725)

* fix(request-panel)/websocket and grpc tooltip overflow fixed in request panel (usebruno#8544)

* fix(request-panel)/websocket and grpx tooltip overflow fixed in request panel

* added test ids and updated the locators for request panel icons

* test(auth): fix modified-indicator inherit spec test (usebruno#8550)

* test(auth): fix modified-indicator inherit spec test

* fix(locators): updated locators for inherit

* feat(description): file binary description implementation (usebruno#8434)

* Add description support to file body entries

Covers the UI table, FileEntry schema, .bru and .yml file persistence,
OpenCollection converters, and end-to-end tests.

* chore: update @opencollection/types to version 0.10.0 and adjust related code

* fix: ensure placeholder is displayed correctly in description editor

* fix: improve column resizing logic in EnvironmentVariablesTable

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* fix: remove unused import of FileEntry in body.ts

* feat: enhance file handling and selection logic in various components

* test: refactor file description tests for improved readability and structure

* refactor: streamline test setup for binary file selection

* test: improve comments for clarity in file body description tests

* refactor: simplify selection update logic in collections slice

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* fix(mount): show requests that failed to load in the collection overview (usebruno#8545)

* fix(mount): show requests that failed to load in the collection overview

Partial/errored requests were being dropped or mis-rendered:

- collection-watcher (v1): the synchronous add path and the change path only
  logged parse errors and never emitted the item, so failed requests never
  reached the renderer. Both now send a partial item, matching the async
  worker path.
- mount v2: reconcile dropped `raw` for errored items; it is now forwarded so
  the item's size can be derived, and size is set for every item.
- RequestsNotLoaded: the relative pathname is computed separator-agnostically
  so it renders on Windows, and errored items are included.

* fix(mount): render v2 requests that failed to parse in the sidebar

An errored request had no parsed `request`, so tree-builder set
`request: undefined`. The main->renderer payload is JSON round-tripped, which
drops undefined keys, so the item reached the renderer without a `request`
property and `isItemARequest` (which requires it) excluded it from the sidebar.
Give errored items an empty `request` object so they survive serialization and
render.

Also render the "not loaded" table from the same filtered list used for the
empty-state check, so errored items are listed consistently.

* fix(mount): guard against NaN size and unstable keys for unloaded requests

* fix(mount): recover unloaded requests on valid re-parse without crashing the reducer

* feat(mount): moved the assignments in change reducer

---------

Co-authored-by: Chirag Chandrashekhar <[email protected]>

---------

Co-authored-by: Pragadesh-45 <[email protected]>
Co-authored-by: sachin-thakur-bruno <[email protected]>
Co-authored-by: Pooja <[email protected]>
Co-authored-by: Sid <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Chirag Chandrashekhar <[email protected]>
Co-authored-by: Chirag Chandrashekhar <[email protected]>
Co-authored-by: Bijin A B <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange error message: url argument is not a string or URL.

5 participants