no uniqueness enforcement on core_userrole table
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 598
- Forks
- 168
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 86
Description
Version
3.28.18
Describe the bug
The core_userrole table is not enforcing uniqueness constraints ...
galaxy=> select pulp_id,object_id,content_type_id,role_id,user_id,domain_id from core_userrole where object_id='3953';
pulp_id | object_id | content_type_id | role_id | user_id | domain_id
--------------------------------------+-----------+-----------------+--------------------------------------+---------+-----------
ed7f4879-9ce4-4fec-bc4e-9ba2f82ef089 | 3953 | 90 | b4b70856-51d1-4143-92f5-55cced716263 | 1737 |
018accc3-6934-70f7-bbbd-4150cf9b8610 | 3953 | 90 | b4b70856-51d1-4143-92f5-55cced716263 | 1737 |
(2 rows)
To Reproduce
We use pulpcore.plugin.util.assign_role to set users as namespace owners. Our helper function is here ...
https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/utils/rbac.py#L63-L65
Theoretically, calling that multiple times would cause the duplicate entries but I have no confirmed.
Expected behavior
Only one row should be allowed for user_id + object_id + role_id (and maybe domain?)
Additional context
Originally found in galaxy.ansible.com's database
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pulpcore.plugin.util.assign_role, using the linked galaxy_ng/app/utils/rbac.py lines 63-65 as the caller, and inspect how rows are created in core_userrole. Confirm which fields define a duplicate, including whether domain_id belongs in the key. Done means repeated role assignment cannot create duplicate rows and the behavior is covered by appropriate database or application tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100