Skip to content

fix(generate-code): double cookie in generate code when libcurl is selected - #9271

Merged
sachin-thakur-bruno merged 2 commits into
usebruno:mainfrom
sachin-thakur-bruno:fix/generate-code-cookie
Sep 16, 2026
Merged

sachin-thakur-bruno merged 2 commits into
usebruno:mainfrom
sachin-thakur-bruno:fix/generate-code-cookie

Conversation

@sachin-thakur-bruno

@sachin-thakur-bruno sachin-thakur-bruno commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The C/libcurl snippet generator add the Cookie header twice: once through CURLOPT_HTTPHEADER and again through CURLOPT_COOKIE.

BRU-4549

Problem

This was caused by HTTPSnippet’s case-sensitive handling of the cookie header.

Fix

Added isLibcurl check (target === 'c' && client === 'libcurl') alongside the existing isCurl check, so both targets now get the cookie header renamed to Cookie before being handed to HTTPSnippet.

Added libcurl tests to cover duplicate cookies, casing, special characters, and cookie merging.

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
    • Fixed generated C/libcurl code to use consistent Cookie header casing.
    • Prevented duplicate cookie options when lowercase and title-case cookie headers are combined.
  • Tests
    • Added coverage for cookie header handling in C/libcurl code generation, including casing normalization and merging with existing headers.

@coderabbitai

coderabbitai Bot commented Sep 16, 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: 5366d66b-8721-421b-ad6a-422551358927

📥 Commits

Reviewing files that changed from the base of the PR and between b00c318 and b52ab39.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js

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


Walkthrough

The snippet generator renames a cookie-header helper parameter without changing behavior. New tests cover lowercase cookie renaming and merging for C/libcurl output.

Changes

Cookie Header Handling

Layer / File(s) Summary
Cookie header normalization
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
The helper parameter is renamed to capitalizeCookieHeaderName. The existing capitalization behavior remains unchanged.
Libcurl cookie tests
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
Tests verify lowercase cookie renaming and merging with an existing Cookie header. Both tests confirm that CURLOPT_COOKIE is not emitted.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to b52ab

This change is described as renaming a cookie-header parameter and adding libcurl test coverage for cookie casing and merging. No verified defect was established against the current code, so there is no concrete blocking risk identified for merge at this time.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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: fixing duplicate cookie generation for libcurl code snippets.
✨ 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

Cookie names align in the stream
Libcurl prints the intended dream
Lowercase headers rise to Cookie
Merged values stay neat and looky
Tests guard each tiny seam
Snippets flow like a tidy stream

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

@sachin-thakur-bruno
sachin-thakur-bruno merged commit 7d0f89a into usebruno:main Sep 16, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants