Bug tags need to be a JSON list, but documentation says plain text

Bug #256697 reported by Markus Korn
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

According to the WADL Description the 'tags' argument has to be separated by whitespace, but this returns a HTTPError:

In [12]: b = launchpad.bugs.createBug(target="https://api.staging.launchpad.net/beta/ubuntu", title="this is a test", description="this is the description of the test\nThis bug was created by launchpadlib", tags="foo bar")
---------------------------------------------------------------------------
<class 'launchpadlib.errors.HTTPError'> Traceback (most recent call last)

/media/disk-1/python-launchpad-bugs/launchpadlib.connector/<ipython console> in <module>()

/media/disk-1/lp_api/launnchpadlib/changed.lists/launchpadlib/resource.py in __call__(self=<launchpadlib.resource.NamedOperation object at 0xcbee50>, **kwargs={'description': 'this is the description of the test\nThis bug was created by launchpadlib', 'tags': 'foo bar', 'target': 'https://api.staging.launchpad.net/beta/ubuntu', 'title': 'this is a test'})
    238 extra_headers = { 'Content-type' : media_type }
    239 response, content = self.root._browser._request(
--> 240 url, in_representation, http_method, extra_headers=extra_headers)
        url = u'https://api.staging.launchpad.net/beta/bugs'
        in_representation = 'description=this+is+the+description+of+the+test%0AThis+bug+was+created+by+launchpadlib&title=this+is+a+test&ws.op=createBug&target=https%3A%2F%2Fapi.staging.launchpad.net%2Fbeta%2Fubuntu&tags=foo+bar'
        http_method = 'post'
        extra_headers = {'Content-type': 'application/x-www-form-urlencoded'}
    241
    242 if response.status == 201:

/media/disk-1/lp_api/launnchpadlib/changed.lists/launchpadlib/_browser.py in _request(self=<launchpadlib._browser.Browser object at 0xcbee10>, url=u'https://api.staging.launchpad.net/beta/bugs', data='description=this+is+the+description+of+the+test%...taging.launchpad.net%2Fbeta%2Fubuntu&tags=foo+bar', method='post', media_type='application/json', extra_headers={'Content-type': 'application/x-www-form-urlencoded'})
     70 # Turn non-2xx responses into exceptions.
     71 if response.status // 100 != 2:
---> 72 raise HTTPError(response, content)
        global HTTPError = <class 'launchpadlib.errors.HTTPError'>
        response = {'status': '400', 'content-length': '15', 'via': '1.1 wildcard.staging.launchpad.net', 'x-powered-by': 'Zope (www.zope.org), Python (www.python.org)', 'vary': 'Accept-Encoding', 'server': 'zope.server.http (HTTP)', 'connection': 'close', 'date': 'Sun, 10 Aug 2008 18:17:31 GMT', 'content-type': 'text/plain'}
        content = 'tags: [foo bar]'
     73 return response, content
     74

<class 'launchpadlib.errors.HTTPError'>: HTTP Error 400: Bad Request

Revision history for this message
Markus Korn (thekorn) wrote :

Ok, this is a bit confusing. A json encoded representation of a list seems to be necessary:

In [23]: x = simplejson.dumps(["boo","bar"])

In [24]: b = launchpad.bugs.createBug(target="https://api.staging.launchpad.net/beta/ubuntu", title="this is a test", description="this is the description of the test\nThis bug was created by launchpadlib", tags=x)

In [25]: b
Out[25]: <bug at https://api.staging.launchpad.net/beta/bugs/256503>

Can this json serialization be done internally? - this is also a reason why setting boolean values is not working as expected.

launchpad.bugs.createBug(target="https://api.staging.launchpad.net/beta/ubuntu", title="this is a test", description="this is the description of the test\nThis bug was created by launchpadlib", private=True)

this fails with a HTTPError, content = "private: got 'unicode', expected bool: u'True'"

Revision history for this message
Leonard Richardson (leonardr) wrote :

After discussion I've decided that a JSON-encoded list is the best way to represent the list of tags, even in an argument to a named operation. However, it should be possible to make launchpadlib serialize lists and other non-strings to JSON data structures transparently.

I'm not sure how the "separated by spaces" thing ended up in the documentation for that method, but at any rate it should be changed to "a list."

Revision history for this message
Gavin Panella (allenap) wrote :

IBug.tags has the description "Separated by whitespace.", which is probably where the misleading doc came from.

Gavin Panella (allenap)
Changed in launchpadlib:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Eleanor Berger (intellectronica) wrote :

I don't think that this is just a Malone bug - there should be tasks for both (or maybe separate bugs). The description should be made clearer, but launchpadlib should not require you to serialize lists manually.

Revision history for this message
Eleanor Berger (intellectronica) wrote :

> there should be tasks for both (or maybe separate bugs)

There is already a Launchpadlib bug, bug #270628, and it's fixed, so this really is just about describing the argument correctly. My comment above is nonsense.

tags: added: bugtag
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.