fix(codegen): uppercase HTTP method in generated code snippets#8738
fix(codegen): uppercase HTTP method in generated code snippets#8738yeti-detective wants to merge 1 commit into
Conversation
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>
|
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)
WalkthroughGenerated snippets now uppercase HTTP methods before HAR conversion, with a regression test confirming lowercase ChangesSnippet method normalization
Estimated code review effort: 2 (Simple) | ~5 minutes 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 |
Summary
Generated code snippets (Generate Code → curl/Python/etc.) emit the HTTP method exactly as stored in the collection file. Because a
.bru/.ymlrequest can store the method lowercase (e.g.method: post), the exported snippet becomes:curl --request post ...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:
…but the code generator passed it through verbatim:
So the runtime and codegen paths disagree on method casing.
Fix
Uppercase the method in
snippet-generator.jsso exported code matches what Bruno sends on the wire, mirroring the executor's normalization.Testing
snippet-generator.spec.jsasserting a lowercasepostmethod produces-X POSTin the snippet.npm test --workspace=packages/bruno-app -- snippet-generator→ 55 passed.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests