Skip to content

fix: reassign HttpHeaders after delete in Angular client#3988

Open
joshkaplinsky wants to merge 3 commits into
hey-api:mainfrom
joshkaplinsky:fix/angular-http-headers-immutable
Open

fix: reassign HttpHeaders after delete in Angular client#3988
joshkaplinsky wants to merge 3 commits into
hey-api:mainfrom
joshkaplinsky:fix/angular-http-headers-immutable

Conversation

@joshkaplinsky
Copy link
Copy Markdown

Angular's HttpHeaders is immutable, .delete() returns a new instance with the header removed rather than mutating in place. The result was not being reassigned to opts.headers, so Content-Type was silently never removed on bodyless requests.

Fixes #3987.

  • Reassign opts.headers = opts.headers.delete('Content-Type') in the Angular client gen

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@joshkaplinsky is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: 53ff1d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 3, 2026
@joshkaplinsky joshkaplinsky changed the title fix: reassign HttpHeaders after delete in Angular client fix: reassign HttpHeaders after delete in Angular client Jun 3, 2026
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — fixes a subtle immutability bug in the Angular client where HttpHeaders.delete() was called without capturing its return value, silently leaving Content-Type present on bodyless requests.

  • Reassign opts.headers = opts.headers.delete('Content-Type') in client-angular to respect Angular's immutable HttpHeaders.
  • Regenerate all affected test snapshots across OpenAPI 2.0.x / 3.0.x / 3.1.x and both plugins/clients paths.
  • Add changeset for @hey-api/openapi-ts patch release.

Pullfrog  | View workflow run | Using Kimi K2𝕏

// remove Content-Type header if body is empty to avoid sending invalid requests
if (opts.body === undefined || opts.serializedBody === '') {
opts.headers.delete('Content-Type');
opts.headers = opts.headers.delete('Content-Type');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ mergeHeaders returns Angular's HttpHeaders, and delete() returns a new instance. Without reassignment, opts.headers retains the old reference and Content-Type leaks to bodyless requests. Good catch, confirmed by Angular source docs.

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — fixes a subtle immutability bug in the Angular client where HttpHeaders.delete() was called without capturing its return value, silently leaving Content-Type present on bodyless requests.

  • Reassign opts.headers = opts.headers.delete('Content-Type') in client-angular to respect Angular's immutable HttpHeaders.
  • Regenerate all affected test snapshots across OpenAPI 2.0.x / 3.0.x / 3.1.x and both plugins/clients paths.
  • Add changeset for @hey-api/openapi-ts patch release.

Pullfrog  | View workflow run | Using Kimi K2𝕏

// remove Content-Type header if body is empty to avoid sending invalid requests
if (opts.body === undefined || opts.serializedBody === '') {
opts.headers.delete('Content-Type');
opts.headers = opts.headers.delete('Content-Type');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ mergeHeaders returns Angular's HttpHeaders, and delete() returns a new instance. Without reassignment, opts.headers retains the old reference and Content-Type leaks to bodyless requests. Good catch, confirmed by Angular source docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.21%. Comparing base (82e9f18) to head (53ff1d4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3988   +/-   ##
=======================================
  Coverage   39.21%   39.21%           
=======================================
  Files         607      607           
  Lines       21468    21468           
  Branches     6345     6331   -14     
=======================================
  Hits         8418     8418           
  Misses      10626    10626           
  Partials     2424     2424           
Flag Coverage Δ
unittests 39.21% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 3, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3988

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3988

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3988

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3988

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3988

@hey-api/spec-types

npm i https://pkg.pr.new/@hey-api/spec-types@3988

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3988

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3988

commit: 53ff1d4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular Client Content-Type header not stripped on bodyless requests

1 participant