Releasing v3.24.1#120
Merged
Merged
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
cb-karthikp
approved these changes
Jun 3, 2026
There was a problem hiding this comment.
PR Complexity Score: 2.5 - Simple
View Breakdown
- Lines Changed: 64
- Files Changed: 7
- Complexity Added: 5
- Raw Score: 29.78
Overview
This PR releases version 3.24.1 of the Chargebee Node client with a critical bug fix for how the Content-Length header is calculated. It ensures compatibility with Node’s fetch/undici (≥ 7.26.0) for requests containing non-ASCII payloads. The change updates request construction logic, adds regression tests, and bumps version metadata.
Key Changes
- Fixes
Content-Lengthheader computation to useBuffer.byteLength(data, 'utf8')instead of the JavaScript stringlength, preventing under-declared content lengths for multi-byte characters and avoidingRequest body length does not match content-length headererrors. - Adds tests for ASCII form-urlencoded request bodies to confirm that
Content-Lengthmatches the UTF-8 byte length of the serialized body. - Adds tests for multi-byte JSON payloads (e.g. accented characters, CJK, emoji) to ensure
Content-Lengthreflects UTF-8 byte length and is greater than the JS character count, guarding against regressions. - Bumps the client version to 3.24.1 across metadata and environment configuration, and documents the bug fix and tests in the changelog.
Risks & Considerations
- Any downstream code or middleware that assumes
Content-Lengthmatches JS string length rather than UTF-8 byte length might behave differently, though this change aligns with HTTP and Node standards. - The fix relies on
Buffer.byteLengthwith'utf8'; if future encodings or non-UTF-8 bodies are introduced, this logic may need revisiting. - Reviewers should verify that all request paths using
RequestWrapperrely on this unified code path for settingContent-Lengthso there are no remaining edge cases.
File-level change summary
| File | Change summary |
|---|---|
| CHANGELOG.md | Added v3.24.1 release notes describing the Content-Length bug fix and associated tests. |
| VERSION | Bumped library version from 3.24.0 to 3.24.1. |
| package-lock.json | Updated package version metadata from 3.24.0 to 3.24.1 in the lockfile. |
| package.json | Bumped npm package version from 3.24.0 to 3.24.1. |
| src/RequestWrapper.ts | Changed Content-Length header calculation to use Buffer.byteLength(data, 'utf8') instead of data.length. |
| src/environment.ts | Updated clientVersion constant to v3.24.1. |
| test/requestWrapper.test.ts | Added tests verifying Content-Length uses UTF-8 byte length for ASCII form-urlencoded and multi-byte JSON bodies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v3.24.1 (2026-06-03)
Bug Fixes:
Content-Lengthheader being computed from the JavaScript string length (UTF-16 code units) instead of the UTF-8 byte length. Requests with non-ASCII payloads (e.g. accented characters, CJK, emoji) under-declaredContent-Lengthand were rejected by Node'sfetch/undici (≥ 7.26.0) withRequest body length does not match content-length header. The header is now computed viaBuffer.byteLength(data, 'utf8'). ResolvesContent-Lengthrequest header is set to the string character count instead of the UTF-8 byte length →TypeError: fetch failedon any non-ASCII request body #119Tests:
Content-Lengthmatches the UTF-8 byte length of the serialized body.Content-Lengthmatches the UTF-8 byte length and is greater than the JS character count, ensuring the regression cannot return.