Skip to content

fix: Correct GetRegionAvailability response type#897

Merged
zliang-akamai merged 2 commits intolinode:mainfrom
glennpratt:glennpratt/get-region-availability-list
Mar 3, 2026
Merged

fix: Correct GetRegionAvailability response type#897
zliang-akamai merged 2 commits intolinode:mainfrom
glennpratt:glennpratt/get-region-availability-list

Conversation

@glennpratt
Copy link
Contributor

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
Contributor Author

Awaiting #898

Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

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

Unit test passed on my end, thanks for putting up the fix!

@psnoch-akamai Can we add integration test for this endpoint later?

Copy link
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@zliang-akamai zliang-akamai merged commit 32b19c6 into linode:main Mar 3, 2026
10 checks passed
@zliang-akamai zliang-akamai added the breaking-change for breaking changes in the changelog. label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change for breaking changes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants