Skip to content

fix!: Correct HostedRunner image struct fields and JSON tags to match API#4104

Open
austenstone wants to merge 3 commits intogoogle:masterfrom
austenstone:fix-hosted-runner-image-fields
Open

fix!: Correct HostedRunner image struct fields and JSON tags to match API#4104
austenstone wants to merge 3 commits intogoogle:masterfrom
austenstone:fix-hosted-runner-image-fields

Conversation

@austenstone
Copy link
Contributor

Summary

Fix incorrect JSON field names on HostedRunner and HostedRunnerImageDetail structs that don't match the GitHub API response, and rename the Go struct fields to align with the API spec.

Supersedes #4102 — recreated as a single commit under my identity to resolve a CLA issue caused by a Copilot-authored gofmt commit in the original PR.

Problem

The HostedRunner struct uses json:"image_details" but the GitHub API returns the field as "image". Similarly, HostedRunnerImageDetail.SizeGB uses json:"size_gb" but the API returns "size".

This means API responses were not being deserialized correctly into these structs.

Changes

Struct Field Before (Go / JSON) After (Go / JSON)
HostedRunner Image ImageDetails / json:"image_details" Image / json:"image"
HostedRunnerImageDetail Size SizeGB / json:"size_gb" Size / json:"size"

Both Go field names and JSON tags are updated to match the API spec. Accessors regenerated via go generate.

Breaking Change

This is a breaking change for anyone referencing the old Go field names (ImageDetails, SizeGB) or constructing JSON with the old field names. However, actual API responses were never being parsed correctly with the old tags, so this is effectively a bugfix.

Testing

  • All existing hosted runner tests pass
  • Marshal/unmarshal tests updated for both org and enterprise endpoints
  • Generated accessor tests pass

… API

Fix incorrect JSON field names on HostedRunner and HostedRunnerImageDetail
structs that don't match the GitHub API response, and rename the Go struct
fields to align with the API spec.

- HostedRunner: ImageDetails/image_details -> Image/image
- HostedRunnerImageDetail: SizeGB/size_gb -> Size/size

BREAKING CHANGE: Renamed Go struct fields (ImageDetails -> Image,
SizeGB -> Size) and their JSON tags. The old JSON tags never matched the
API, so this is effectively a bugfix.

Supersedes google#4102
@austenstone austenstone changed the title fix!: Correct HostedRunner image struct fields and JSON tags to match API fix: Correct HostedRunner image struct fields and JSON tags to match API Mar 17, 2026
@gmlewis gmlewis changed the title fix: Correct HostedRunner image struct fields and JSON tags to match API fix!: Correct HostedRunner image struct fields and JSON tags to match API Mar 17, 2026
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Mar 17, 2026
RunnerGroupID *int64 `json:"runner_group_id,omitempty"`
Platform *string `json:"platform,omitempty"`
ImageDetails *HostedRunnerImageDetail `json:"image_details,omitempty"`
Image *HostedRunnerImageDetail `json:"image,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

According to https://docs.github.com/en/rest/actions/hosted-runners?apiVersion=2022-11-28#list-github-hosted-runners-for-an-organization, HostedRunner contains the image_details field and not image.

Currently, the library uses 2022-11-28 API version:

defaultAPIVersion = "2022-11-28"

This PR should be done as part of #4077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants