Skip to content

Fix idempotent Google Workspace user status updates - #128

Open
cxcollins wants to merge 1 commit into
mainfrom
connor.collins/IGA-1362/idempotent-gws-disable
Open

Fix idempotent Google Workspace user status updates#128
cxcollins wants to merge 1 commit into
mainfrom
connor.collins/IGA-1362/idempotent-gws-disable

Conversation

@cxcollins

Copy link
Copy Markdown

Summary

  • avoid updating an account when its Google Workspace suspension state already matches the requested value
  • add a regression test for disabling an already suspended account through update_user_status

Fixes: IGA-1362

Test plan

  • go test ./...
  • make lint

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

IGA-1362

if _, _, err := c.updateUserStatus(context.Background(), args); err != nil {
t.Fatalf("updateUserStatus: %v", err)
}
if state.putCount != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: This only covers the short-circuit path. A regression that made updateUserStatus always return early (e.g. the guard becoming unconditional) would still pass. Consider adding a case where the requested state differs from the current one and asserting putCount == 1 plus the resulting Suspended value, mirroring TestDisableEnableUser_IdempotentAndPayload.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Connector PR Review: Fix idempotent Google Workspace user status updates

Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 90e5345686e8.
Review mode: full
View review run

Review Summary

Scanned the full PR diff (pkg/connector/actions.go, pkg/connector/actions_test.go) for security and correctness. The change adds a pre-read of the user via GetUserForProvisioning and short-circuits updateUserStatus when the requested is_suspended value already matches, mirroring the existing disableUserActionHandler/enableUserActionHandler pattern; errors are wrapped with %w and the google-workspace: prefix, the extra Users.Get call needs no scope beyond the write scope already required for the PUT, and no dependency manifests changed. No blocking issues found; one test-coverage suggestion.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • pkg/connector/actions_test.go:255 - the new test only asserts the no-op path; add a case where the requested status differs so the PUT path stays covered.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/connector/actions_test.go`:
- Around line 239-258: TestUpdateUserStatus_IsIdempotentForSuspendedUser only exercises
  the short-circuit branch of updateUserStatus (already-suspended user, expect zero PUTs).
  A regression that made the early return unconditional would still pass. Add a second
  case in the same test (or a sibling test) that starts from Suspended false, calls
  updateUserStatus with is_suspended true, and asserts state.putCount == 1 and the user
  ends up Suspended, mirroring the structure of TestDisableEnableUser_IdempotentAndPayload.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found.

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.

1 participant