api.user.grant_roles: issue when no username is passed and obj is not None
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 101
- Forks
- 62
- Avg merge
- 15h 15m
- Merged PRs (30d)
- 1
Description
Looking at https://github.com/plone/plone.api/blob/a8361ed4f24df027cd3afae68a30454ad5b299e1/src/plone/api/user.py#L365-L383
It seems that calling api.user.grant_roles(user=user, obj=obj) will remove all the roles because we will invoke:
https://github.com/plone/plone.api/blob/a8361ed4f24df027cd3afae68a30454ad5b299e1/src/plone/api/user.py#L382
passing None as a username.
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 in src/plone/api/user.py at lines 365-383 and trace how grant_roles handles user, username, and obj. Reproduce the call with a user and object, then verify that omitting the username no longer removes existing roles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, authorization
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100