Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch delegation using the REST API broken on old instances #313

Closed
stephenfin opened this issue Sep 21, 2019 · 0 comments
Closed

Patch delegation using the REST API broken on old instances #313

stephenfin opened this issue Sep 21, 2019 · 0 comments
Labels

Comments

@stephenfin
Copy link
Member

stephenfin commented Sep 21, 2019

Some users have reported that delegation via the REST API, specifically using git-pw, is broken. Specifically, they see this issue:

$ git-pw patch update --delegate bhelgaas 1164343
...
{u'delegate': [u"User 'bhelgaas' is not a maintainer for project 'Linux PCI development'"]}

However, a quick look at the project overview page for said project shows that this is not the case. Seems like an obvious bug.

@stephenfin stephenfin added the bug label Sep 21, 2019
stephenfin added a commit that referenced this issue Sep 24, 2019
There have been reports of people being unable to delegate patches to
themselves, despite being a maintainer or the project to which the patch
is associated.

The issue is a result of how we do a check for whether the user is a
maintainer of the patch's project [1]. This check is checking if a given
'User.id' is in the list of items referenced by
'Project.maintainer_project'. However, 'Project.maintainer_project' is a
backref to 'UserProfile.maintainer_projects'. This means we're comparing
'User.id' and 'UserProfile.id'. Boo.

This wasn't seen in testing since we've had a post-save callback [2] for some
time that ensures we always create a 'UserProfile' object whenever we create a
'User' object. This also means we won't have an issue on deployments initially
deployed after that post-save callback was added, a 'User' with id=N will
always have a corresponding 'UserProfile' with id=N. However, that's not true
for older deployments such as the ozlabs.org one.

[1] https://github.com/getpatchwork/patchwork/blob/89c924f9bc/patchwork/api/patch.py#L108-L111
[2] https://github.com/getpatchwork/patchwork/blob/89c924f9bc/patchwork/models.py#L204-L210

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #313
Reported-by: Bjorn Helgaas <helgaas@kernel.org>
(cherry picked from commit ab35df8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant