fix: reassign HttpHeaders after delete in Angular client#3988
fix: reassign HttpHeaders after delete in Angular client#3988joshkaplinsky wants to merge 3 commits into
HttpHeaders after delete in Angular client#3988Conversation
|
|
|
@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 detectedLatest commit: 53ff1d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
HttpHeaders after delete in Angular client
There was a problem hiding this comment.
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')inclient-angularto respect Angular's immutableHttpHeaders. - 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-tspatch release.
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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')inclient-angularto respect Angular's immutableHttpHeaders. - 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-tspatch release.
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'); |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |

Angular's
HttpHeadersis immutable,.delete()returns a new instance with the header removed rather than mutating in place. The result was not being reassigned toopts.headers, soContent-Typewas silently never removed on bodyless requests.Fixes #3987.
opts.headers = opts.headers.delete('Content-Type')in the Angular client gen