Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override base url #836

Merged
merged 5 commits into from
May 7, 2024
Merged

Conversation

Yang-33
Copy link
Contributor

@Yang-33 Yang-33 commented May 1, 2024

Changes

The constructor of line-bot-sdk-nodejs client modifies the given config, which should ideally behave immutably. Reusing the config as is can lead to unexpected behavior(see below sample #2). This change ensures that the config is not unintentionally overwritten.

How to reproduce this

(normal)

// #1 (it works, but `config`'s baseURL is updated expectedly)
const config = {
  channelAccessToken: "token-token",
};
const blobClient = new messagingApi.MessagingApiBlobClient(config);
// config.baseURL -> https://api-data.line.me (Unexpected, but it works)

(this issue)
Executing the following code does not set api.line-data.me. A workaround is to clone the config, but this is not convenient and debugging can be troublesome.

// #2 (blob doesn't work, because the first unexpected update blocks blob client uses expected baseURL)
const config = {
  channelAccessToken: "token-token",
};
const client = new messagingApi.MessagingApiClient(config);
// config.baseURL -> https://api.line.me
const blobClient = new messagingApi.MessagingApiBlobClient(config);
// config.baseURL -> https://api.line.me, not https://api-data.line.me (Unexpected, and it won't work)

@Yang-33 Yang-33 marked this pull request as ready for review May 1, 2024 14:45
@Yang-33 Yang-33 requested review from mokuzon and habara-k May 1, 2024 14:46
@Yang-33 Yang-33 merged commit 2b7783d into line:master May 7, 2024
3 checks passed
@Yang-33 Yang-33 deleted the do-not-override-base-url branch May 7, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants