Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9348128
D2221.id7663.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2221.id7663.diff
View Options
diff --git a/swh/web/common/service.py b/swh/web/common/service.py
--- a/swh/web/common/service.py
+++ b/swh/web/common/service.py
@@ -279,11 +279,9 @@
for match in matches:
match['from_revision'] = hashutil.hash_to_hex(match['from_revision'])
+ origin = None
if match['origin_url']:
origin = storage.origin_get({'url': match['origin_url']})
- else:
- # Fallback to origin-id for idx-storage with outdated db
- origin = storage.origin_get({'id': match['id']})
del match['origin_url']
if 'id' in match:
diff --git a/swh/web/tests/api/views/test_origin.py b/swh/web/tests/api/views/test_origin.py
--- a/swh/web/tests/api/views/test_origin.py
+++ b/swh/web/tests/api/views/test_origin.py
@@ -634,3 +634,33 @@
self.assertEqual(rv.status_code, 400, rv.content)
mock_idx_storage.assert_not_called()
+
+ def test_api_origin_metadata_search_missing_origin_url(self):
+ with patch('swh.web.common.service.idx_storage') as mock_idx_storage:
+ mock_idx_storage.origin_intrinsic_metadata_search_fulltext \
+ .side_effect = lambda conjunction, limit: [{
+ 'from_revision': (
+ b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed '
+ b'\xf2U\xfa\x05B8'),
+ 'metadata': {'author': 'Jane Doe'},
+ 'origin_url': None,
+ 'tool': {
+ 'configuration': {
+ 'context': ['NpmMapping', 'CodemetaMapping'],
+ 'type': 'local'
+ },
+ 'id': 3,
+ 'name': 'swh-metadata-detector',
+ 'version': '0.0.1'
+ }
+ }]
+
+ url = reverse('api-1-origin-metadata-search',
+ query_params={'fulltext': 'Jane Doe'})
+ rv = self.client.get(url)
+
+ self.assertEqual(rv.status_code, 200, rv.content)
+ self.assertEqual(rv['Content-Type'], 'application/json')
+ self.assertEqual(len(rv.data), 0)
+ mock_idx_storage.origin_intrinsic_metadata_search_fulltext \
+ .assert_called_with(conjunction=['Jane Doe'], limit=70)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 6:13 PM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222163
Attached To
D2221: Filter out metadata missing origin url
Event Timeline
Log In to Comment