[BUG] Error occurs when executing `updateLIFFApp` in `LiffClient`
Bug Report
Describe the bug
I found that an error occurs when I execute updateLIFFApp in LiffClient.
To Reproduce
Steps to reproduce the behavior:
- Run this code
import * as line from "@line/bot-sdk";
const liffClient = new line.liff.LiffClient({
channelAccessToken: process.env.LINE_TOKEN,
});
const res = await liffClient.updateLIFFApp("2006142821-LN7nErlM", {
view: {
url: "https://new2.example.com",
},
});
consola.log("res", res);
- Get an error
$ node run.js
undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:5472:19)
at successSteps (node:internal/deps/undici/undici:5454:27)
at fullyReadBody (node:internal/deps/undici/undici:4381:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async consumeBody (node:internal/deps/undici/undici:5463:7)
at async LiffClient.updateLIFFAppWithHttpInfo (file:///path/to/repo/node_modules/@line/bot-sdk/dist/liff/api/liffClient.js:124:43)
at async LiffClient.updateLIFFApp (file:///path/to/repo/node_modules/@line/bot-sdk/dist/liff/api/liffClient.js:109:17)
at async file:///path/to/repo/run.js:7:13
Node.js v22.6.0
Expected behavior
No errors should occur.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: macOS 14.5
- Node.js Version 22.6.0
- line-bot-sdk-nodejs version(s) 9.4.0
Additional context
An error occurred in the function call, but the URL was updated, so the API execution was successful.
I have also confirmed that the following shell script runs successfully.
set -uex
curl -vvv -X PUT https://api.line.me/liff/v1/apps/2006142821-LN7nErlM \
-H "Authorization: Bearer ${LINE_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"view": {
"url": "https://new.example.com"
}
}'
It is likely that the error is occurring because the response body from the API is an empty string, which cannot be converted to JSON. ref: https://github.com/line/line-bot-sdk-nodejs/blob/365bb036aebbd8a47f309ef473d1a61dc36c939d/lib/liff/api/liffClient.ts#L179