Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ def get_collection_items(
for s in sorts:
prop = s
order = '+'
if s[0] in ['+', '-']:
if s and s[0] in ['+', '-']:
order = s[0]
prop = s[1:]

if prop not in p.fields.keys():
msg = 'bad sort property'
msg = 'bad sortby property'
return api.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidParameterValue', msg)
Expand Down
9 changes: 9 additions & 0 deletions tests/api/test_itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# Authors: Tom Kralidis <tomkralidis@gmail.com>
# John A Stevenson <jostev@bgs.ac.uk>
# Colin Blackburn <colb@bgs.ac.uk>
# Francesco Bartoli <xbartolone@gmail.com>
#
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
# Copyright (c) 2025 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -285,6 +287,13 @@ def test_get_collection_items(config, api_):
assert links[4]['rel'] == 'next'
assert links[5]['rel'] == 'collection'

req = mock_api_request({
'sortby': ''
})
rsp_headers, code, response = get_collection_items(api_, req, 'obs')

assert code == HTTPStatus.BAD_REQUEST

req = mock_api_request({
'sortby': 'bad-property',
'stn_id': '35'
Expand Down
Loading