[PATCH] Fix issue with delegation of patch via REST API

Bjorn Helgaas helgaas at kernel.org
Thu Sep 26 04:51:20 AEST 2019


On Wed, Sep 25, 2019 at 04:33:35PM +0100, Stephen Finucane wrote:
> On Tue, 2019-09-24 at 14:12 -0500, Bjorn Helgaas wrote:
> > On Tue, Sep 24, 2019 at 09:45:16AM +0100, Stephen Finucane wrote:
> > > On Mon, 2019-09-23 at 15:39 -0500, Bjorn Helgaas wrote:
> > > > On Sat, Sep 21, 2019 at 07:30:46PM +0100, Stephen Finucane wrote:
> > > > > 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.
> > > > > ...
> > > > I tried the instance at https://patchwork.kernel.org/project/linux-pci/list/
> > > > to see if it was new enough to work without this fix.  But it also
> > > > fails, slightly differently:
> > > > 
> > > >   $ git config -l | grep "^pw"
> > > >   pw.server=https://patchwork.kernel.org/api/1.1
> > > >   pw.project=linux-pci
> > > >   pw.token=...
> > > > 
> > > >   $ git-pw patch update --delegate helgaas 11151519
> > > >   More than one delegate found: helgaas
> > > > 
> > > > Is this another manifestation of the same bug or something else?
> > > 
> > > This is a different issue and, unlike the other one, is more feature
> > > than bug. This is happening because the search for a particular user is
> > > returning multiple matches. We match on username, first name, last name
> > > and email, so I imagine you have multiple user accounts on the instance
> > > and there might be a conflict between an email address of one account
> > > and a username of another? (Let me know if this isn't the case). The
> > > easy solution is to use a more specific match. I'd suggest just using
> > > the email address associated with your user account ([1] suggests this
> > > is 'bhelgaas at google.com'). We could also support lookup by user ID
> > > (which would guarantee a single match) but I haven't added that to git-
> > > pw yet since it didn't seem that usable.
> > 
> > Still no workey.  I'm cursed.  The web "Delegate to" dropdown menu
> > includes "bhelgaas" and my profile seems to be associated with
> > "bhelgaas" (at least, that's the name in the upper right of the web
> > page when I'm logged in).
> > 
> >   $ git-pw patch update --delegate bhelgaas 11151519
> >   {u'delegate': [u"User 'bhelgaas' is not a maintainer for project 'Linux PCI development list'"]}
> >   $ git-pw patch update --delegate bhelgaas at google.com 11151519
> >   {u'delegate': [u"User 'bhelgaas' is not a maintainer for project 'Linux PCI development list'"]}
> >   $ git-pw patch update --delegate bjorn at helgaas.com 11151519
> >   No matching delegates found: bjorn at helgaas.com
> > 
> > https://patchwork.kernel.org/user/ also claims I'm a maintainer for
> > https://patchwork.kernel.org/project/linux-pci/list/ and shows both
> > bhelgaas at google.com and bjorn at helgaas.com as email addresses.
> 
> I'll have a look into this but I've no ideas off the top of my head. If
> you're comfortable with Python, could you add a couple of print
> statements to log what we're requesting from the API and what we're
> getting back and share them here? If not, I'll try look into this next
> week.

I am able to change the *state*, e.g.,

  $ git-pw patch update --state accepted 11151519
  $ git-pw patch update --state new 11151519

seem to work fine.

Not sure if this has enough information to be useful to you, but this
is the output from:

  git-pw --debug patch update --delegate bhelgaas at google.com 11151519

2019-09-25 13:43:04,838 - git_pw.patch - DEBUG - Updating patch: id=11151519, commit_ref=None, state=None, archived=None
2019-09-25 13:43:04,843 - git_pw.config - DEBUG - Retrieved 'server' setting from git-config
2019-09-25 13:43:04,843 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2019-09-25 13:43:04,847 - git_pw.config - DEBUG - Retrieved 'project' setting from git-config
2019-09-25 13:43:04,847 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2019-09-25 13:43:04,847 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2019-09-25 13:43:04,847 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2019-09-25 13:43:04,847 - git_pw.api - DEBUG - GET https://patchwork.kernel.org/api/1.1/users/
2019-09-25 13:43:04,851 - git_pw.config - DEBUG - Retrieved 'token' setting from git-config
2019-09-25 13:43:04,852 - git_pw.config - DEBUG - Retrieved 'token' setting from cache
2019-09-25 13:43:04,853 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): patchwork.kernel.org:443
2019-09-25 13:43:05,414 - urllib3.connectionpool - DEBUG - https://patchwork.kernel.org:443 "GET /api/1.1/users/?q=bhelgaas%40google.com&project=linux-pci HTTP/1.1" 200 167
2019-09-25 13:43:05,415 - git_pw.api - DEBUG - Got response
2019-09-25 13:43:05,416 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2019-09-25 13:43:05,416 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2019-09-25 13:43:05,416 - git_pw.api - DEBUG - PATCH https://patchwork.kernel.org/api/1.1/patches/11151519/, data=[('delegate', 13257)]
2019-09-25 13:43:05,416 - git_pw.config - DEBUG - Retrieved 'token' setting from cache
2019-09-25 13:43:05,416 - git_pw.config - DEBUG - Retrieved 'token' setting from cache
2019-09-25 13:43:05,417 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): patchwork.kernel.org:443
2019-09-25 13:43:05,926 - urllib3.connectionpool - DEBUG - https://patchwork.kernel.org:443 "PATCH /api/1.1/patches/11151519/ HTTP/1.1" 400 93
2019-09-25 13:43:05,927 - git_pw.api - ERROR - JSON response
2019-09-25 13:43:05,928 - git_pw.api - ERROR - {u'delegate': [u"User 'bhelgaas' is not a maintainer for project 'Linux PCI development list'"]}
2019-09-25 13:43:05,928 - git_pw.config - DEBUG - Retrieved 'debug' setting from cache
Traceback (most recent call last):
  File "/home/bhelgaas/bin/git-pw", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/bhelgaas/src/git-pw/git_pw/patch.py", line 180, in update_cmd
    patch = api.update('patches', patch_id, data)
  File "/home/bhelgaas/src/git-pw/git_pw/api.py", line 277, in update
    return patch(url, data).json()
  File "/home/bhelgaas/src/git-pw/git_pw/api.py", line 169, in patch
    _handle_error('update', exc)
  File "/home/bhelgaas/src/git-pw/git_pw/api.py", line 167, in patch
    rsp.raise_for_status()
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://patchwork.kernel.org/api/1.1/patches/11151519/


More information about the Patchwork mailing list