Skip to content

fix: Allow removing runner group networks - #4541

Open
austenstone wants to merge 2 commits into
google:masterfrom
austenstone:austenstone-runner-network-detachment
Open

austenstone wants to merge 2 commits into
google:masterfrom
austenstone:austenstone-runner-network-detachment

Conversation

@austenstone

@austenstone austenstone commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Add RemoveNetworkConfiguration to organization and enterprise runner-group update requests, following UpdateTeamRequest.RemoveParentTeam. Setting it sends "network_configuration_id": null and takes precedence over a supplied ID. The value-receiver marshaler supports both values and pointers without mutation. Creates and responses are unchanged.

The Go 1.26.0 encoding/json repro shows that *string behaves identically with omitempty and omitzero: nil omits the field, new("network-id") sends a string, and new("") sends "". Neither tag produces JSON null. Empty-string behavior is preserved for compatibility, but empty-string detachment is unverified. Both PATCH schemas allow null: organization and enterprise.

Regression tests cover omission, assignment, empty-string compatibility, explicit null, flag precedence, preservation of other fields, value/pointer marshaling, request immutability, and both native PATCH bodies. The null cases fail without the marshalers. On Go 1.26.0, runner-group race tests, all-module script/test.sh race tests, script/fmt.sh, script/generate.sh, script/lint.sh, and OpenAPI metadata validation pass. No live API writes were made for this revision.

This revises the earlier omitzero implementation and still needs maintainer agreement on explicit-null removal. Needed by integrations/terraform-provider-github#3274, which remains gated on a merged and released SDK fix.

Copilot assisted with implementation, tests, and this description.

@google-cla

google-cla Bot commented Sep 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Add explicit removal flags for organization and enterprise runner group updates, preserving existing omission and string behavior.
@austenstone
austenstone force-pushed the austenstone-runner-network-detachment branch from 9788c28 to c4d4c88 Compare September 10, 2026 22:05
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Sep 10, 2026
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (c5074ea) to head (6cf8993).
⚠️ Report is 20 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4541      +/-   ##
==========================================
+ Coverage   98.54%   98.59%   +0.04%     
==========================================
  Files         196      197       +1     
  Lines       17938    18344     +406     
==========================================
+ Hits        17677    18086     +409     
+ Misses        261      258       -3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread github/actions_runner_groups.go
@gmlewis

gmlewis commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

@austenstone - just like in another recent PR, we now have a CLA problem because an agent signed a commit that was pushed to this PR.

The following contributors were found for this pull request:

✅ https://github.com/google/go-github/commit/b0fc528fc916672eb5d41e81defdbb91c1aa4416 Author: @austenstone <aus******ne​@github.com>
❌ https://github.com/google/go-github/commit/b0fc528fc916672eb5d41e81defdbb91c1aa4416 Co-Author: @Copilot <223556219+Copilot​@users.noreply.github.com>

So now, you can either clean up the commits locall and force-push the changes to this PR to get rid of the bot's commits or you can close this PR and open a brand new one. Your choice, but we cannot continue this PR with the current CLA state, unfortunately.

Keep explicit JSON null removal separate from empty-string compatibility. Document the primitive-pointer encoding contract and exercise the removal flag through organization and enterprise update requests.
@austenstone
austenstone force-pushed the austenstone-runner-network-detachment branch from b0fc528 to 6cf8993 Compare September 18, 2026 20:18

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @austenstone.
One wording suggestion, otherwise, LGTM.

cc: @stevehipwell - @Not-Dhananjay-Mishra

Comment thread CONTRIBUTING.md
Comment on lines +416 to +424
For optional primitive fields where the zero value has API semantics, use a
pointer with `omitempty`. A nil pointer omits the field, while a pointer to the
zero value includes it, such as `false`, `0`, or `""`.

Neither `omitempty` nor `omitzero` makes a pointer to a zero value encode as
JSON `null`. When an update must distinguish omission, assignment, and explicit
removal using `null`, follow `UpdateTeamRequest.RemoveParentTeam`: add a Go-only
removal flag and a value-receiver `MarshalJSON` method. This supports marshaling
both request values and pointers without changing the request.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How about this?

Suggested change
For optional primitive fields where the zero value has API semantics, use a
pointer with `omitempty`. A nil pointer omits the field, while a pointer to the
zero value includes it, such as `false`, `0`, or `""`.
Neither `omitempty` nor `omitzero` makes a pointer to a zero value encode as
JSON `null`. When an update must distinguish omission, assignment, and explicit
removal using `null`, follow `UpdateTeamRequest.RemoveParentTeam`: add a Go-only
removal flag and a value-receiver `MarshalJSON` method. This supports marshaling
both request values and pointers without changing the request.
Optional pointer fields should use `omitempty`: a nil pointer omits the field,
while a pointer to a zero value such as `false`, `0`, or `""` includes it.
`omitzero` behaves identically for pointers, so prefer `omitempty`.
Neither tag can send JSON `null`, so an update that must distinguish omission,
assignment, and removal follows `UpdateTeamRequest.RemoveParentTeam` in
`github/teams.go`: a Go-only removal flag tagged `json:"-"`, plus a
value-receiver `MarshalJSON` that also serves `*T` call sites. `new("")` sends
an empty string, not `null`.

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

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants