Skip to content

fix: Correct GetRegionAvailability response type#897

Open
glennpratt wants to merge 1 commit intolinode:mainfrom
glennpratt:glennpratt/get-region-availability-list
Open

fix: Correct GetRegionAvailability response type#897
glennpratt wants to merge 1 commit intolinode:mainfrom
glennpratt:glennpratt/get-region-availability-list

Conversation

@glennpratt
Copy link

The regions/{regionID}/availability API endpoint returns a JSON array of availability records (one per plan), not a single object.

https://techdocs.akamai.com/linode-api/reference/get-region-availability

✔️ How to Test

https://gist.github.com/glennpratt/e427a03cb749ccec3c3041c6e6396aea

go test -run TestGetRegionAvailability ./test/unit/...

The regions/{regionID}/availability API endpoint returns a JSON array
of availability records (one per plan), not a single object.

https://techdocs.akamai.com/linode-api/reference/get-region-availability
Copilot AI review requested due to automatic review settings February 18, 2026 01:00
@glennpratt glennpratt requested a review from a team as a code owner February 18, 2026 01:00
@glennpratt glennpratt requested review from ezilber-akamai and yec-akamai and removed request for a team February 18, 2026 01:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the response type for the GetRegionAvailability function to correctly return an array of availability records (one per plan) instead of a single object, aligning with the actual Linode API behavior documented at https://techdocs.akamai.com/linode-api/reference/get-region-availability.

Changes:

  • Updated GetRegionAvailability to return []RegionAvailability instead of *RegionAvailability
  • Modified caching logic to properly handle array responses
  • Updated test fixture and assertions to match the corrected array response format

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
regions_availability.go Changed return type from pointer to single object to array, updated response handling and caching logic
test/unit/region_test.go Updated test assertions to access array elements instead of direct object properties
test/unit/fixtures/region_availability_get.json Changed fixture from single object to array containing availability records

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@srager13
Copy link

I can confirm that this is an issue. I get this error when calling GetRegionAvailability() in v1.61.0:
[002] json: cannot unmarshal array into Go value of type linodego.RegionAvailability

@glennpratt glennpratt force-pushed the glennpratt/get-region-availability-list branch from e11f5c2 to 965df95 Compare February 19, 2026 01:07
@glennpratt
Copy link
Author

Awaiting #898

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.

3 participants

Comments