Skip to content

Commit 35e58fe

Browse files
authored
Merge branch 'develop' into DS-version
2 parents 8ed4467 + b89b044 commit 35e58fe

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [9.11.2] - 2025-04-15
9+
### Fixed
10+
- [#564](https://github.com/unity-sds/unity-data-services/pull/564) fix: check collection when querying single granule
11+
812
## [9.11.1] - 2025-04-10
913
### Fixed
1014
- [#561](https://github.com/unity-sds/unity-data-services/pull/561) fix: docker error

cumulus_lambda_functions/uds_api/dapa/granules_dapa_query_es.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def get_single_granule(self, granule_id):
172172
'size': 1,
173173
'sort': [{'id': {'order': 'asc'}}],
174174
'query': {'bool': {'must': [{
175-
'term': {'id': granule_id}
175+
'term': {'id': granule_id}}, {
176+
'term': {'collection': self.__collection_id},
176177
}]}}
177178
}
178179
LOGGER.debug(f'granules_query_dsl: {granules_query_dsl}')
@@ -182,7 +183,7 @@ def get_single_granule(self, granule_id):
182183
granules_query_dsl)
183184
LOGGER.debug(f'granules_query_result: {granules_query_result}')
184185
if len(granules_query_result['hits']['hits']) < 1:
185-
raise ValueError(f'cannot find granule for : {granule_id}')
186+
return None
186187

187188
each_granules_query_result_stripped = granules_query_result['hits']['hits'][0]['_source']
188189
self_link = Link(rel='self', target=f'{self.__base_url}/{WebServiceConstants.COLLECTIONS}/{self.__collection_id}/items/{each_granules_query_result_stripped["id"]}', media_type='application/json', title=each_granules_query_result_stripped["id"]).to_dict(False)

cumulus_lambda_functions/uds_api/granules_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ async def get_single_granule_dapa(request: Request, collection_id: str, granule_
136136
except Exception as e:
137137
LOGGER.exception('failed during get_granules_dapa')
138138
raise HTTPException(status_code=500, detail=str(e))
139+
if granules_result is None:
140+
raise HTTPException(status_code=404, detail={'message': f'no granule with id: {granule_id} in collection: {collection_id}'})
139141
return granules_result
140142

141143
@router.delete("/{collection_id}/items/{granule_id}")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="cumulus_lambda_functions",
15-
version="9.11.1",
15+
version="9.11.2",
1616
packages=find_packages(),
1717
install_requires=install_requires,
1818
package_data={

tests/integration_tests/test_uds_api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,26 @@ def test_version_get(self):
247247
print(json.dumps(response_json))
248248
return
249249

250+
251+
def test_single_granule_get_wrong_collection(self):
252+
# post_url = f'{self.uds_url}collections/urn:nasa:unity:uds_local_test:DEV1:CHRP_16_DAY_REBIN___10/items/urn:nasa:unity:uds_local_test:DEV1:CHRP_16_DAY_REBIN___10:SNDR.SS1330.CHIRP.20230101T0000.m06.g001.L1_J1.std.v02_48.G.200101070318_REBIN'
253+
post_url = f'{self.uds_url}collections/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-02___001/items/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001:test_file10'
254+
headers = {
255+
'Authorization': f'Bearer {self.bearer_token}',
256+
}
257+
print(post_url)
258+
query_result = requests.get(url=post_url, headers=headers,)
259+
self.assertEqual(query_result.status_code, 404, f'wrong status code. {query_result.text}')
260+
response_json = json.loads(query_result.text)
261+
print(json.dumps(response_json))
262+
263+
post_url = f'{self.uds_url}collections/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001/items/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001:test_file10'
264+
query_result = requests.get(url=post_url, headers=headers,)
265+
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
266+
response_json = json.loads(query_result.text)
267+
print(json.dumps(response_json))
268+
return
269+
250270
def test_create_new_collection(self):
251271
post_url = f'{self.uds_url}collections/' # MCP Dev
252272
headers = {

0 commit comments

Comments
 (0)