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

bugfix: int32 is converted to incorrect string #416

Merged
merged 4 commits into from
Jan 22, 2024

Conversation

mekpavit
Copy link
Contributor

@mekpavit mekpavit commented Jan 21, 2024

Currently, stringify macro in api.pebble doesn't handle int32 Go type properly. It directly uses string(...) to convert int32 to string which will generate a UTF-8 character corresponding to the value of int instead. For example, string(57) will result in "9" instead of "57". This bug makes MessagingApiAPI.GetFollowers(start string, limit int32) to be nearly impossible to use.

To fix this, this PR changes add another condition to stringify macro for Integer type. With this change, it will use strconv.FormatInteger(int64(...), 10) instead of string(...) which yield a correct string value.

Apart from the bugfix, I also refactor api.pebble a bit to re-use stringify macro for any place required to use string type. And also add another condition to stringify macro to not doing an unnecessary string-conversion again for string type.

@CLAassistant
Copy link

CLAassistant commented Jan 21, 2024

CLA assistant check
All committers have signed the CLA.

@mekpavit mekpavit changed the title bugfix: fix int32 is converted to incorrect string bugfix: int32 is converted to incorrect string Jan 21, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e159509) 55.19% compared to head (78ae4ba) 55.19%.

❗ Current head 78ae4ba differs from pull request most recent head 00c0394. Consider uploading reports for the commit 00c0394 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #416   +/-   ##
=======================================
  Coverage   55.19%   55.19%           
=======================================
  Files          87       87           
  Lines        5479     5479           
=======================================
  Hits         3024     3024           
  Misses       2233     2233           
  Partials      222      222           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@Yang-33 Yang-33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks @mekpavit !

@Yang-33 Yang-33 merged commit 247a707 into line:master Jan 22, 2024
5 checks passed
"github.com/line/line-bot-sdk-go/v8/linebot/messaging_api"
)

func TestGetFollowers_ItShouldCorrectlyPassLimitQueryParameter(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Yang-33
Copy link
Contributor

Yang-33 commented Jan 22, 2024

This bug was fixed as v8.2.1 , thank you!

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.

4 participants