Skip to content

Commit

Permalink
Fix handling of optional query filter options
Browse files Browse the repository at this point in the history
Query filter options like `sortOrder` and `sortBy` are optional. The
existing code handled these incorrectly, causing 500 responses.
  • Loading branch information
maxtruxa committed Dec 21, 2023
1 parent cab951e commit e55b5da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vscoffline/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ def on_post(self, req, resp):
#flags = vsc.QueryFlags.NoneDefined
criteria = req.media['filters'][0]['criteria']

if req.media['filters'][0]['sortOrder']:
if req.media['filters'][0].get('sortOrder'):
sortorder = vsc.SortOrder(req.media['filters'][0]['sortOrder'])

if req.media['filters'][0]['sortBy']:
if req.media['filters'][0].get('sortBy'):
sortby = vsc.SortBy(req.media['filters'][0]['sortBy'])

# Flags can be used for version management, but it appears the client doesn't care what's sent back
#if req.media['flags']:
# flags = vsc.QueryFlags(req.media['flags'])

# Unused
#pagenumber = req.media['filters'][0]['pageNumber']
#pagesize = req.media['filters'][0]['pageSize']
#pagenumber = req.media['filters'][0].get('pageNumber', 0)
#pagesize = req.media['filters'][0].get('pageSize', 500)
#log.info(f'CRITERIA {criteria}, flags {flags}, sortby {sortby}, sortorder {sortorder}')

# If no order specified, default to InstallCount (e.g. popular first)
Expand Down

0 comments on commit e55b5da

Please sign in to comment.