Skip to content

fix(cli): merge headers instead of overwriting#1381

Merged
ChiragAgg5k merged 1 commit intomasterfrom
fix/cli-headers-merge
Mar 16, 2026
Merged

fix(cli): merge headers instead of overwriting#1381
ChiragAgg5k merged 1 commit intomasterfrom
fix/cli-headers-merge

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Mar 16, 2026

Summary

This PR fixes the CLI SDK template to properly merge headers instead of overwriting them.

Problem

In templates/cli/lib/sdks.ts, the client.headers object was being directly overwritten:

client.headers = {
  "x-sdk-name": "Command Line",
  // ... other headers
};

This caused any existing headers set by the Client instance to be lost.

Solution

Changed both sdkForConsole and sdkForProject functions to spread existing headers before adding new ones:

client.headers = {
  ...client.headers,
  "x-sdk-name": "Command Line",
  // ... other headers
};

Changes

  • Added ...client.headers spread operator in both sdkForConsole and sdkForProject functions
  • Regenerated examples/cli/lib/sdks.ts with the fix

Testing

  • Template changes verified
  • SDK regenerated successfully

Summary by CodeRabbit

  • Bug Fixes
    • Improved SDK header handling to prevent loss of pre-existing headers during initialization.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 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: 1dde4f7e-44fb-4dcf-a484-0e6a813440dc

📥 Commits

Reviewing files that changed from the base of the PR and between a562ad7 and bdac0b2.

📒 Files selected for processing (1)
  • templates/cli/lib/sdks.ts

📝 Walkthrough

Walkthrough

The change adds header spreading in templates/cli/lib/sdks.ts within two functions (sdkForConsole and sdkForProject). Existing client headers are now preserved before adding new SDK-specific headers (x-sdk-name, x-sdk-platform, x-sdk-language, x-sdk-version, and user-agent).

Changes

Cohort / File(s) Summary
Header Preservation
templates/cli/lib/sdks.ts
Spreads existing client headers into new headers object in sdkForConsole and sdkForProject, ensuring pre-existing headers are retained while applying SDK-specific header overrides.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Headers spread like clover so green,
Pre-existing ones, now preserved and seen,
SDK headers stand tall and proud,
In the bundle of code, none lost in the crowd! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(cli): merge headers instead of overwriting' directly summarizes the main change: preventing header overwriting by merging headers instead.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cli-headers-merge
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@ChiragAgg5k ChiragAgg5k merged commit 8dfee3f into master Mar 16, 2026
54 checks passed
@ChiragAgg5k ChiragAgg5k deleted the fix/cli-headers-merge branch March 16, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants