LoginRadius / LoginRadius/node-js-sdk
[BUG] SDK fails to make proper requests when provided with non-ascii chars
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 9
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
The implementation to make requests in the SDK assumes an ascii encoding (meaning each character in the JSON string will map to 1 byte) but this is not always true.
Example request that fails when using the SDK but works using any other HTTP client (`axios`, `curl`, LR API docs, etc.):
`POST https://api.loginradius.com/identity/v2/manage/account`
```json
{
"FirstName": "José",
"Email": [
{
"Type": "Primary",
"Value": "whatever@mailinator.com"
}
],
"Password": "fake-password"
}
```
The problem is that the "Content-Length" header is set using the length of the string and not the length of the byte array. For example, the word "José" has a length of 4 characters but it has a length of 5 bytes when turned into a byte array (buffer). That means that the SDK is incapable of sending that perfectly valid request to the LR API.
The change needed is rather simple (one line change) and I can create a PR if needed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the SDK's request implementation and find where Content-Length is calculated. Reproduce the issue with the provided JSON containing "José", then verify that the header uses the byte-array length and that the request succeeds like the other HTTP clients described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100