Skip to content

Commit 157b6bb

Browse files
Only use add method when the value is not ellipsis (#339)
* Only use `add` method when the value is not ellipsis * add unittest to ensure all properties are returned when requested in search * changelog entry for #339 * changelog entry for #339 Co-authored-by: Jeff Albrecht <[email protected]>
1 parent 1e3ba0a commit 157b6bb

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Fixed
1212
* Bumped uvicorn version to 0.17 (from >=0.12, <=0.14) to resolve security vulnerability related to websockets dependency version ([#343](https://github.com/stac-utils/stac-fastapi/pull/343))
13+
* `AttributeError` and/or missing properties when requesting the complete `properties`-field in searches. Added test. ([#339](https://github.com/stac-utils/stac-fastapi/pull/339))
14+
1315

1416
## [2.3.0]
1517

stac_fastapi/extensions/stac_fastapi/extensions/core/fields/request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def _get_field_dict(fields: Optional[Set[str]]) -> Dict:
3434
if parent not in field_dict:
3535
field_dict[parent] = {key}
3636
else:
37-
field_dict[parent].add(key)
37+
if field_dict[parent] is not ...:
38+
field_dict[parent].add(key)
3839
else:
3940
field_dict[field] = ... # type:ignore
4041
return field_dict

stac_fastapi/sqlalchemy/tests/api/test_api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,23 @@ def test_search_line_string_intersects(
285285
assert resp.status_code == 200
286286
resp_json = resp.json()
287287
assert len(resp_json["features"]) == 1
288+
289+
290+
def test_app_fields_extension_return_all_properties(
291+
load_test_data, app_client, postgres_transactions
292+
):
293+
item = load_test_data("test_item.json")
294+
postgres_transactions.create_item(item, request=MockStarletteRequest)
295+
296+
resp = app_client.get(
297+
"/search", params={"collections": ["test-collection"], "fields": "properties"}
298+
)
299+
assert resp.status_code == 200
300+
resp_json = resp.json()
301+
feature = resp_json["features"][0]
302+
assert len(feature["properties"]) >= len(item["properties"])
303+
for expected_prop, expected_value in item["properties"].items():
304+
if expected_prop in ("datetime", "created", "updated"):
305+
assert feature["properties"][expected_prop][0:19] == expected_value[0:19]
306+
else:
307+
assert feature["properties"][expected_prop] == expected_value

0 commit comments

Comments
 (0)