Skip to content

fix: restore default axios request headers#7820

Open
j4ln wants to merge 1 commit intousebruno:mainfrom
j4ln:bugfix/default-accept-header
Open

fix: restore default axios request headers#7820
j4ln wants to merge 1 commit intousebruno:mainfrom
j4ln:bugfix/default-accept-header

Conversation

@j4ln
Copy link
Copy Markdown

@j4ln j4ln commented Apr 21, 2026

Description

  • Commit ca0412b replaced the axios instance's defaults.headers.common object entirely. This inadvertently removed the default Accept header from axios.
  • Fix by assigning the User-Agent header as an additional property to the existing common headers rather than replacing it. This preserves the axios defaults.

Fixes #7819.

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

  • Bug Fixes

    • Preserve existing default HTTP headers when configuring requests and ensure a consistent bruno-runtime User-Agent is added without removing other defaults (e.g., Accept).
  • Tests

    • Added unit and integration tests plus an HTTP request check to validate that Accept remains present and User-Agent is set as expected.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 383edfa9-5f38-41db-92cd-9fb7b2fda0b0

📥 Commits

Reviewing files that changed from the base of the PR and between 38de3f6 and bb1ccda.

📒 Files selected for processing (5)
  • packages/bruno-cli/src/utils/axios-instance.js
  • packages/bruno-cli/tests/utils/axios-instance.spec.js
  • packages/bruno-electron/src/ipc/network/axios-instance.js
  • packages/bruno-electron/tests/network/axios-instance.spec.js
  • packages/bruno-tests/collection/echo/echo default request headers.bru
✅ Files skipped from review due to trivial changes (3)
  • packages/bruno-electron/src/ipc/network/axios-instance.js
  • packages/bruno-cli/src/utils/axios-instance.js
  • packages/bruno-cli/tests/utils/axios-instance.spec.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/bruno-tests/collection/echo/echo default request headers.bru
  • packages/bruno-electron/tests/network/axios-instance.spec.js

Walkthrough

Changed Axios instance initialization to set User-Agent by mutating instance.defaults.headers.common['User-Agent'] instead of replacing the entire common headers object; added tests (Jest + collection) asserting the default Accept header is preserved and User-Agent is set to bruno-runtime/....

Changes

Cohort / File(s) Summary
Axios Instance Header Configuration
packages/bruno-cli/src/utils/axios-instance.js, packages/bruno-electron/src/ipc/network/axios-instance.js
Set runtime User-Agent by mutating instance.defaults.headers.common['User-Agent'] instead of replacing instance.defaults.headers.common, preserving existing default headers (notably Accept).
Header Default Tests
packages/bruno-electron/tests/network/axios-instance.spec.js, packages/bruno-cli/tests/utils/axios-instance.spec.js, packages/bruno-tests/collection/echo/echo default request headers.bru
Add tests that assert outgoing requests retain Axios’s default Accept header (application/json present) and include User-Agent with bruno-runtime/... prefix.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

Headers hum a quieter tune,
Accept stays steady, User-Agent in tune,
A tiny tweak, a stable line,
Requests now travel, intact, resigned,
Small change — smoother runtime.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main fix: restoring default axios request headers by preserving the Accept header.
Linked Issues check ✅ Passed PR directly addresses #7819 by restoring the missing Accept header through proper header mutation instead of replacement.
Out of Scope Changes check ✅ Passed All changes are in-scope: axios instance fixes in CLI and Electron, corresponding test coverage, and integration test for header verification.

✏️ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 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-cli/src/utils/axios-instance.js`:
- Line 96: The CLI axios instance sets default headers
(instance.defaults.headers.common['User-Agent'] and the default Accept header)
but lacks test coverage; add a unit test mirroring the Electron tests that loads
the CLI axios instance module and asserts the default 'User-Agent' equals
`bruno-runtime/${CLI_VERSION}` and that the default 'Accept' header is
present/expected. Create or update a test file (e.g., bruno-cli tests under
tests/network/axios-instance.spec.js) to import the axios-instance module used
in packages/bruno-cli/src/utils/axios-instance.js, and add assertions for
instance.defaults.headers.common['User-Agent'] and
instance.defaults.headers.common['Accept'] to ensure parity with the Electron
test suite.
🪄 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: 1a780940-290c-41d2-88c1-d4139a1d951e

📥 Commits

Reviewing files that changed from the base of the PR and between c4dc0bc and 6f9bc08.

📒 Files selected for processing (3)
  • packages/bruno-cli/src/utils/axios-instance.js
  • packages/bruno-electron/src/ipc/network/axios-instance.js
  • packages/bruno-electron/tests/network/axios-instance.spec.js

Comment thread packages/bruno-cli/src/utils/axios-instance.js
@Pragadesh44-Bruno
Copy link
Copy Markdown
Collaborator

Hey @j4ln, thanks for your contribution to this PR. Could you please review and merge the PR I have raised here: j4ln#1?

I’ve slightly updated your tests, consolidated your commits into one, and added proper comments. Let me know if you have any doubts. Please merge it and let me know so I can pass it to the team for review.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Apr 24, 2026
Assigning `defaults.headers.common = { 'User-Agent': ... }` replaced the
entire common headers object, nuking axios's built-in default:

  Accept: application/json, text/plain, */*

This caused servers relying on content-negotiation to receive requests
with no Accept header. Fix by extending the existing object with a
property assignment instead.

Add regression tests for both electron and CLI axios instances verifying
that Accept is preserved and User-Agent is set correctly.

Co-Authored-By: James <j4ln@posteo.net>
Co-Authored-By: Pragadesh-45 <temporaryg7904@gmail.com>
@j4ln j4ln force-pushed the bugfix/default-accept-header branch from 38de3f6 to bb1ccda Compare April 24, 2026 20:05
@j4ln
Copy link
Copy Markdown
Author

j4ln commented Apr 24, 2026

Hey @Pragadesh44-Bruno thanks for the review. I've merged those changes in now. I've re consolidated the commits into a single one and rebased against main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing default Accept header from v3.2.0 onwards

2 participants