Skip to content

CRASM-3710: Fix User Pending Bug - Prod#1502

Open
aloftus23 wants to merge 2 commits into
develop-prod-01-15-2026from
prod-pending-user-fix
Open

CRASM-3710: Fix User Pending Bug - Prod#1502
aloftus23 wants to merge 2 commits into
develop-prod-01-15-2026from
prod-pending-user-fix

Conversation

@aloftus23
Copy link
Copy Markdown
Contributor

@aloftus23 aloftus23 commented Jun 3, 2026

🗣 Description

Fixes users staying in the pending registration queue after a successful approve, including when org assignment already exists in the DB or register/approve was already completed.

Backend: add_user_to_org_v2 is idempotent (returns existing role on duplicate; IntegrityError fallback).
Frontend (RegionUsers.tsx): “Already approved” path completes org + invite_pending cleanup; 30s refresh of pending/member tables (paused during dialogs / hidden tab).

💭 Motivation and context

Prod logs showed: register/approve succeeding, then POST /v2/organizations/{id}/users returning 500 (duplicate role_user_id_organization_id), so update_user with invite_pending: false never ran. The UI could also treat “already approved” as done and remove the row without clearing pending. Stale pending rows (roles: [] after Manage Users) made the frontend retry org add and hit that 500.

🧪 Testing

Created backend and frontend unit tests.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.
  • Bump major, minor, patch, pre-release, and/or build versions as appropriate via the bump_version script if this repository is versioned and the changes in this PR warrant a version bump.
  • Create a pre-release (necessary if and only if the pre-release version was bumped).

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release (necessary if and only if the version was bumped).

… assignment idempotent so duplicate role inserts return 200 instead of 500, allowing update_user to clear invite_pending. When register/approve reports already approved, complete org assignment and invite_pending cleanup instead of only showing the dialog. Refresh pending and member tables every 30s while the page is open.
@aloftus23 aloftus23 self-assigned this Jun 3, 2026
@aloftus23 aloftus23 changed the base branch from develop to develop-prod-01-15-2026 June 3, 2026 16:50
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