Skip to content

fix(codegen): uppercase HTTP method in generated code snippets#8738

Open
yeti-detective wants to merge 1 commit into
usebruno:mainfrom
yeti-detective:fix/codegen-uppercase-http-method
Open

fix(codegen): uppercase HTTP method in generated code snippets#8738
yeti-detective wants to merge 1 commit into
usebruno:mainfrom
yeti-detective:fix/codegen-uppercase-http-method

Conversation

@yeti-detective

@yeti-detective yeti-detective commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Generated code snippets (Generate Code → curl/Python/etc.) emit the HTTP method exactly as stored in the collection file. Because a .bru/.yml request can store the method lowercase (e.g. method: post), the exported snippet becomes:

  • curl: curl --request post ...
  • Python: conn.request("post", "/oauth/token", ...)

HTTP methods are case-sensitive on the wire (RFC 7231 §4.1), so these run differently from the in-app request: many servers (e.g. Auth0's /oauth/token) reject the verbatim lowercase verb with 400 Bad Request. The request works in Bruno but the copied code doesn't.

Root cause

The request executor already normalizes the method to uppercase before sending:

// packages/bruno-electron/src/ipc/network/index.js
method: (_item.request?.method || 'GET').toString().toUpperCase(),

…but the code generator passed it through verbatim:

// packages/bruno-app/.../GenerateCodeItem/utils/snippet-generator.js
method: request.method,

So the runtime and codegen paths disagree on method casing.

Fix

Uppercase the method in snippet-generator.js so exported code matches what Bruno sends on the wire, mirroring the executor's normalization.

Testing

  • Added a regression test in snippet-generator.spec.js asserting a lowercase post method produces -X POST in the snippet.
  • npm test --workspace=packages/bruno-app -- snippet-generator55 passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Generated cURL snippets now consistently use uppercase HTTP methods, preventing issues when requests use lowercase methods.
  • Tests

    • Added coverage to verify lowercase request methods are converted to uppercase in generated snippets.

The request executor normalizes the method to uppercase before sending
(bruno-electron network/index.js), but the code generator passed
`request.method` through verbatim. A collection storing a lowercase
method (e.g. `method: post`) therefore worked in-app but produced
snippets like `curl --request post` / `conn.request("post", ...)` that
send a verbatim lowercase verb — which many servers reject with 400.

Uppercase the method in the snippet generator so exported code matches
what Bruno sends on the wire.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review 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: Pro

Run ID: f61b4eff-0a17-45fd-bb7e-622c076d4947

📥 Commits

Reviewing files that changed from the base of the PR and between 4f02e61 and 618f0f0.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js

Walkthrough

Generated snippets now uppercase HTTP methods before HAR conversion, with a regression test confirming lowercase post produces -X POST in curl output.

Changes

Snippet method normalization

Layer / File(s) Summary
Normalize and validate HTTP methods
packages/bruno-app/.../utils/snippet-generator.js, packages/bruno-app/.../utils/snippet-generator.spec.js
HAR requests default missing methods to GET and uppercase provided methods; a Jest test verifies lowercase methods generate uppercase curl verbs.

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

Suggested reviewers: bijin-bruno, helloanoop, lohit-bruno

Poem

Lowercase verbs take flight,
Uppercase snippets shine bright.
POST now stands tall,
Consistent for all—
Curl speaks the protocol right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: normalizing HTTP methods to uppercase in generated snippets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

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.

1 participant