feat(app): export request/response as HAR file#8484
Conversation
Adds an 'Export as HAR' action to the response pane that exports the request that was actually sent (item.requestSent) together with the received response as a HAR 1.2 file. - new buildHarLog() exporter in bruno-app utils (with jest specs) - new ResponseHarExport response-pane action component - new renderer:export-har-file ipc handler that prompts for a save location (defaults to <request-name>.har) and writes the file Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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 (1)
WalkthroughAdds HAR export for response data: a HAR builder, an Electron save handler, and a response-pane export control wired into the action menus. ChangesHAR Export Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ResponsePaneActions
participant ResponseHarExport
participant buildHarLog
participant ElectronIPC
participant FileSystem
User->>ResponsePaneActions: Click "Export as HAR"
ResponsePaneActions->>ResponseHarExport: ref.click()
ResponseHarExport->>buildHarLog: buildHarLog({ requestSent, response })
buildHarLog-->>ResponseHarExport: HAR log
ResponseHarExport->>ElectronIPC: invoke('renderer:export-har-file', har, pathname)
ElectronIPC->>FileSystem: chooseFileToSave + writeFile(JSON)
FileSystem-->>ElectronIPC: filePath or cancelled
ElectronIPC-->>ResponseHarExport: result
ResponseHarExport-->>User: success or error toast
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
- response.bodySize now reflects the transferred size (content-length header) instead of the decoded body length, falling back to -1 - redirectURL is only populated for 3xx responses - document the httpVersion and timings approximations - add tests for no-cookie requests and charset content types Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…to feature/export-response-as-har
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/bruno-app/src/components/ResponsePane/ResponseHarExport/index.js (1)
22-41: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winConsider warning users that exported HAR includes raw credentials.
buildHarLogpreserves resolvedAuthorization/Cookieheaders verbatim (by design, per PR objective). HAR files are commonly shared with third parties (DevTools, support tickets, bug reports), so a leaked token/cookie is a realistic risk once this file leaves the user's machine. Consider a confirmation toast/dialog noting that the exported file contains sensitive headers, similar to how browsers warn on HAR export.🤖 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 `@packages/bruno-app/src/components/ResponsePane/ResponseHarExport/index.js` around lines 22 - 41, The HAR export flow in exportHarFile currently shows only a success toast, but it should warn that the generated HAR contains raw sensitive headers. Update the export path in exportHarFile to add a confirmation/notice before or during the export, and include a clear warning about Authorization/Cookie values being preserved by buildHarLog so users know the file may expose credentials. Use the existing exportHarFile, buildHarLog, and toast usage in ResponseHarExport to place the warning where the export is triggered.
🤖 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.
Inline comments:
In `@packages/bruno-app/src/utils/exporters/har.js`:
- Around line 58-82: The HAR request builder is serializing binary request
bodies incorrectly because buildHarRequest uses requestSent.data and
JSON.stringify for non-string payloads. Update buildHarRequest to prefer
requestSent.dataBuffer when present, populate harRequest.postData from the raw
Buffer content, and keep the existing text/JSON fallback only for non-buffer
bodies. Make sure the change is localized to the postData construction logic in
buildHarRequest and still sets mimeType and bodySize correctly.
---
Nitpick comments:
In `@packages/bruno-app/src/components/ResponsePane/ResponseHarExport/index.js`:
- Around line 22-41: The HAR export flow in exportHarFile currently shows only a
success toast, but it should warn that the generated HAR contains raw sensitive
headers. Update the export path in exportHarFile to add a confirmation/notice
before or during the export, and include a clear warning about
Authorization/Cookie values being preserved by buildHarLog so users know the
file may expose credentials. Use the existing exportHarFile, buildHarLog, and
toast usage in ResponseHarExport to place the warning where the export is
triggered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ef69eaa3-afa9-4046-a038-204a9fbfc0e6
📒 Files selected for processing (6)
packages/bruno-app/src/components/ResponsePane/ResponseHarExport/StyledWrapper.jspackages/bruno-app/src/components/ResponsePane/ResponseHarExport/index.jspackages/bruno-app/src/components/ResponsePane/ResponsePaneActions/index.jspackages/bruno-app/src/utils/exporters/har.jspackages/bruno-app/src/utils/exporters/har.spec.jspackages/bruno-electron/src/ipc/network/index.js
requestSent.data may be a parsed JSON object (parseDataFromResponse JSON-parses request bodies), so re-stringifying it loses the original body formatting. Prefer dataBuffer, which holds the exact bytes sent, and keep the stringify path only as a fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Description
Closes #8485. Related to #1636 (HAR import), where export was also requested in the comments.
This PR adds an Export as HAR action to the response pane, letting users export the request/response pair of the last run as a HAR 1.2 file that can be opened in Chrome DevTools, Firefox, or any HAR viewer/tooling.
The export is built from
item.requestSentanditem.response, so the file reflects the request as it was actually sent — interpolated URL, resolved auth headers, and the serialized body — rather than the pre-interpolation template.Changes:
bruno-app/src/utils/exporters/har.js— newbuildHarLog()that convertsrequestSent+responseinto a HAR 1.2 log:encoding: "base64"per specset-cookie) are flattened into separate HAR header entrieshar.spec.js, 8 cases)bruno-app/src/components/ResponsePane/ResponseHarExport/— new response-pane action component following the existingResponseDownloadpattern; wired into the actions row and the "more actions" dropdown for both HTTP and GraphQL requests. Disabled while a response is streaming or when the request failed without a response.bruno-electron— newrenderer:export-har-fileIPC handler (mirrorsrenderer:save-response-to-file) that shows a save dialog defaulting to<request-name>.harand writes the prettified JSON.Contribution Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests