merge fix/team-members-nil-no-wipe (68890d07b4) #101

Merged
pipeline-bot merged 1 commit from fix/team-members-nil-no-wipe into trunk 2026-07-28 14:18:00 +00:00
Contributor
No description provided.
fix(team): omitted spec.members must not evict every team member
All checks were successful
pipeline/ci CI green v68890d07b40f
68890d07b4
ForgejoTeam.spec.members is +optional with omitempty and is absent from the
CRD's required list, so a CR that simply leaves the field out is legal and
decodes to Members == nil. The removal sweep in reconcileTeamMembers treated
spec.members as the authoritative COMPLETE desired set unconditionally, so a
nil field built an empty desiredMemberMap and the sweep called
RemoveTeamMember for EVERY current member.

The failure was silent in every direction that would normally catch it: each
removal logged as a success, no error was appended to memberErrors, and the CR
went Ready=True. The only visible trace was status.memberCount dropping to 0.
Meanwhile every user had lost the org-team membership and the repo access that
team granted them.

Nil now means "membership is not managed by this CR" and the sweep is skipped.
An explicitly-empty list ([]) is still a real assertion of "no members" and
removes everyone, so authoritative membership is unchanged for every CR that
actually sets the field. This is the same unset-vs-empty distinction the
organization reconciler already respects.

Adds internal/controller/forgejoteam_fake_test.go — the first team test —
using the httptest fake-server idiom from forgejobranchprotection_fake_test.go
so the real gitea SDK request path is exercised. It pins all three cases: nil
members removes nobody, an explicit [alice] still sweeps bob, and an explicit
[] still sweeps everyone. Verified red before the fix: the nil case emitted
DELETE /teams/7/members/alice and .../bob.

The CRD lifecycle contract on the Go type said membership is reconciled
authoritatively without qualification; it now documents the nil-vs-empty rule,
and config/crd/bases is regenerated to match.
pipeline-bot deleted branch fix/team-members-nil-no-wipe 2026-07-28 14:18:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/forgejo-operator!101
No description provided.