Skip to content

fix(har): ensure HTTP methods are uppercase to prevent server rejections - #9250

Open
Vineet-Singh-Chauhan wants to merge 1 commit into
usebruno:mainfrom
Vineet-Singh-Chauhan:bugfix/9249-generate-code-emits-http-verbs-in-lowercase
Open

Vineet-Singh-Chauhan wants to merge 1 commit into
usebruno:mainfrom
Vineet-Singh-Chauhan:bugfix/9249-generate-code-emits-http-verbs-in-lowercase

Conversation

@Vineet-Singh-Chauhan

@Vineet-Singh-Chauhan Vineet-Singh-Chauhan commented Sep 14, 2026

Copy link
Copy Markdown

Description

fixes #9249
Generate Code copies the request's method into the snippet exactly as it is held in memory. When that value is lowercase, the generated command is not runnable:

curl --request post --url https://api.example.com/users   # server responds 400

Fix

Fix belongs in buildHar (packages/bruno-common/src/generate-code/har/index.ts), the single canonical Bruno → HAR pipeline, so every target and every future consumer is covered rather than one call site.

Screenshots

Before After

|
image
|
image
|

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.
  • I've run the claude code review skill locally.

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

    • HTTP methods are now consistently rendered in uppercase when generating HAR data and code snippets.
    • Requests with missing methods default to GET.
    • Custom HTTP methods are normalized correctly, improving compatibility with generated cURL, Wget, and raw HTTP commands.
  • Tests

    • Added coverage for lowercase, custom, missing, and non-string HTTP methods.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 41d22efb-379e-4a84-b6a8-e77e55c80b03

📥 Commits

Reviewing files that changed from the base of the PR and between b522245 and 39c327e.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
  • packages/bruno-common/src/generate-code/har/index.spec.ts
  • packages/bruno-common/src/generate-code/har/index.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The change normalizes HTTP methods to uppercase during HAR construction. It applies the normalized method to request signing and HAR output. Tests verify defaults, custom methods, non-string values, and generated command output.

Changes

HTTP Method Normalization

Layer / File(s) Summary
Normalize methods in HAR requests
packages/bruno-common/src/generate-code/har/index.ts
buildHar converts the method to an uppercase string and uses it for EdgeGrid authentication and the assembled HAR request.
Validate method casing and defaults
packages/bruno-common/src/generate-code/har/index.spec.ts, packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
Tests cover lowercase, uppercase, custom, missing, empty, and non-string methods. Snippet tests verify uppercase verbs in curl, wget, and raw HTTP output.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: pooja-bruno

Merge Risk: ⚪ Minimal · up to 39c32

The change consistently uppercases HTTP methods for HAR and generated snippets, with coverage for the affected output paths.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: normalizing HTTP methods to uppercase in HAR generation to prevent server rejections.
✨ 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

Lowercase verbs rise bright and clear
HAR records hold the proper gear
Curl and wget speak with pride
Raw HTTP stands uppercase-wide
Each method finds its rightful stride

Comment @coderabbitai help to get the list of available commands.

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.

Generate Code emits the HTTP verb in lowercase, producing a command servers reject

1 participant