Skip to content

fix(users): clear invite fields by omission when a password is set - #99

Open
atbagan wants to merge 1 commit into
mainfrom
fix/set-password-invite-status
Open

atbagan wants to merge 1 commit into
mainfrom
fix/set-password-invite-status

Conversation

@atbagan

@atbagan atbagan commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Problem

UserService.SetPassword (internal/auth/users.go) replaced User.status with a map that set inviteExpiresAt: "". The User CRD declares status.inviteExpiresAt with format: date-time (unchanged between butler-crds 0.11.0 and 0.22.0), so the apiserver rejects the status update:

User.butler.butlerlabs.dev "e2e-parity-viewer" is invalid: status.inviteExpiresAt: Invalid value: "": inviteExpiresAt in body must be of type date-time: ""

Every invited internal user gets 500 Failed to set password and can never log in. Reproduced on butler-beta on 2026-08-22 with a local server build while creating e2e users for the parity harness.

Change

The post-set-password status omits inviteTokenHash and inviteExpiresAt instead of writing empty strings; replacing the whole status map already clears them. The map is built by activeUserStatus, with a test asserting the invite keys are absent.

Verification

  • CGO_ENABLED=0 go build ./..., go vet ./internal/auth/ clean
  • CGO_ENABLED=0 go test ./internal/auth/ passes (new users_status_test.go)
  • Exercised against butler-beta through the local server: POST /api/admin/users then POST /api/auth/set-password with the invite token now returns 200 and the user logs in (recorded in the parity workstream note).

Out of scope

The console SetPasswordsPage and the missing portal landing page for invites.

SetPassword rewrote User.status with inviteExpiresAt set to an empty
string. The CRD declares that field with format date-time, so the
apiserver rejected every status update and no invited internal user
could ever complete password setup (500 "Failed to set password").

The status written after set-password now omits the invite fields,
which clears the invite without violating the schema.
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