Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

fix: dedupe user-group memberships from usersAndUserGroups - #43

Merged
vondravl merged 1 commit into
mainfrom
fix/dedupe-user-group-memberships
Jul 7, 2026
Merged

vondravl merged 1 commit into
mainfrom
fix/dedupe-user-group-memberships

Conversation

@vondravl

@vondravl vondravl commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Problem

The MIC DB Export workflow failed with:

sqlite3.IntegrityError: UNIQUE constraint failed: user_group_members.user_id, user_group_members.user_group_id

(e.g. https://github.com/gooddata/Services-MIC-Cloud/actions/runs/28851951284, aic_diagnose / preprod)

The /api/v1/layout/usersAndUserGroups API tolerates the same group appearing more than once in a user's userGroups array. process_user_group_members passed those duplicates straight into the user_group_members table, whose PRIMARY KEY (user_id, user_group_id) then aborted the entire export.

Fix

  • process_user_group_members: collect (user_id, user_group_id) pairs into a set, so the junction table receives each membership once (output stays sorted).
  • process_users: dedupe the derived user_group_ids / user_group_count (order-preserving) so they stay consistent with the junction table.
  • Tests for both functions (tests/test_process_users_groups.py).
  • Version 1.16.1 + changelog entry.

🤖 Generated with Claude Code

The layout API tolerates the same group listed more than once in a
user's userGroups. process_user_group_members passed the duplicates
into user_group_members, whose PRIMARY KEY (user_id, user_group_id)
aborted the whole export. Dedupe the pairs, and keep the derived
users.user_group_ids/user_group_count consistent with them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vondravl
vondravl marked this pull request as ready for review July 7, 2026 09:26
@vondravl
vondravl merged commit 18a1fbc into main Jul 7, 2026
1 check passed
@vondravl
vondravl deleted the fix/dedupe-user-group-memberships branch July 7, 2026 09:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant