Store api workaround no longer valid

Bug #1697323 reported by Kit Randel
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapweb
New
Undecided
Unassigned

Bug Description

Due to an older bug (https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1609368), snapweb contains a workaround to list all snaps when searching with an empty query string:

getAll (https://github.com/snapcore/snapweb/blob/master/snappy/app/handlers.go#L76):

 query := r.FormValue("q")
 // This is a workaround until there is a way to get the list of snaps:
 // https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1609368
 if query == "" {
  query = "."
 }

This always worked because the store would ignore the ‘q’ parameter if a section parameter was also provided. However, a few weeks ago we started supporting searching for snaps within a section. This means that if both the ‘q’ and ‘section_name’ parameters are provided, the store will use the ‘q’ parameter to search within a section. Since ‘.’ does not match any snaps, this workaround is currently breaking snapweb.

In the case where the user is attempting to list the contents of a section, snapweb causes the following query to be sent to the store:

GET /api/v1/snaps/search?q=.&section=section_name

To list snaps in a section, the correct API request should be:

GET /api/v1/snaps/search?section=section_name

We will deploy a fix to the store to work around this issue in the short-term, but this workaround should be removed from snapweb as soon as possible. There is currently no case where setting ‘q’ to ‘.’ makes sense.

To list all the featured snaps, or to list the snaps in any other section, send:
GET /api/v1/snaps/search?section=featured

To list all the snaps in the store, send:

Header: 'X-Ubuntu-Store: ubuntu’
Header: ‘X-Ubuntu-Series: 16’
GET /api/v1/snaps

To search for snaps in the store, send:
 /api/v1/snaps/search?q=<search_term>

To search for snaps by name prefix in the store, send:
 /api/v1/snaps/search?name=<search_term>

To search for snaps within a specified section, send: /api/v1/snaps/search?section=section&q=<search_term>

Tags: snapstore
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.