From 56fa8ec5ba7aee44ab6725434e9296bc8a381451 Mon Sep 17 00:00:00 2001 From: DerekFurstPitt Date: Wed, 25 Sep 2024 00:28:15 -0400 Subject: [PATCH] Fixed a bug where datasets within a public collection were not being filtered for excluded fields in get_entity_by_id --- src/app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app.py b/src/app.py index ba749fb3..2ead89db 100644 --- a/src/app.py +++ b/src/app.py @@ -715,6 +715,13 @@ def get_entity_by_id(id): # Response with the dict if public_entity and not user_in_hubmap_read_group(request): final_result = schema_manager.exclude_properties_from_response(fields_to_exclude, final_result) + if normalized_entity_type == 'Collection': + for i, dataset in enumerate(final_result.get('datasets')): + if _get_entity_visibility(normalized_entity_type='Dataset', entity_dict=dataset) != DataVisibilityEnum.PUBLIC or user_in_hubmap_read_group(request): + # If the dataset is non-public, or if the user has read-group access, there is no need to remove fields, continue to the next dataset + continue + dataset_excluded_fields = schema_manager.get_fields_to_exclude('Dataset') + final_result.get('datasets')[i] = schema_manager.exclude_properties_from_response(dataset_excluded_fields, dataset) return jsonify(final_result) """