linode / linodego

Go client for Linode REST v4 API
MIT License
138 stars 81 forks source link

fix: Create request object per-page in getPaginatedResults(...) #536

Closed lgarber-akamai closed 2 months ago

lgarber-akamai commented 2 months ago

📝 Description

This PR fixes a bug that would cause corrupt/partially overridden data to be returned from endpoint methods that implement getPaginatedResults[T any](...) and have a large number of results.

This issue occurred because Resty's request objects are not designed to be executed multiple times. Specifically, the internal Request.Result pointer (initialized by us using SetResult(...)) is not implicitly reset when executing a request multiple times, leading to new data being written on top of existing data.

✔️ How to Test

Unit Testing

make testunit

Manual Testing

Excluding manual testing steps for now since it requires a large number of resources (~ >200).