Skip to content

Commit cdfa71d

Browse files
committed
fix: remove len(global_asset_ids)<=1 guard that silently emptied results for 2+ globalAssetId filters
1 parent 148bd85 commit cdfa71d

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

server/app/interfaces/repository.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,7 @@ def _get_shells(self, request: Request) -> Tuple[Iterator[model.AssetAdministrat
463463
for specific_asset_id in specific_asset_ids
464464
)
465465
)
466-
and (
467-
len(global_asset_ids) <= 1
468-
and (not global_asset_ids or shell.asset_information.global_asset_id in global_asset_ids)
469-
)
466+
and (not global_asset_ids or shell.asset_information.global_asset_id in global_asset_ids)
470467
),
471468
aas,
472469
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) 2026 the Eclipse BaSyx Authors
2+
#
3+
# This program and the accompanying materials are made available under the terms of the MIT License, available in
4+
# the LICENSE file of this project.
5+
#
6+
# SPDX-License-Identifier: MIT
7+
8+
import base64
9+
import json
10+
import unittest
11+
12+
from basyx.aas import model
13+
from basyx.aas.adapter.aasx import DictSupplementaryFileContainer
14+
from basyx.aas.examples.data.example_aas import create_full_example
15+
from werkzeug.test import Client
16+
17+
from app.interfaces.repository import WSGIApp
18+
19+
BASE_PATH = "/api/v3.1"
20+
21+
22+
def _encode_asset_id(name: str, value: str) -> str:
23+
payload = json.dumps({"name": name, "value": value})
24+
return base64.urlsafe_b64encode(payload.encode()).decode()
25+
26+
27+
class ShellsAssetIdsTest(unittest.TestCase):
28+
def setUp(self) -> None:
29+
self.example_data = create_full_example()
30+
app = WSGIApp(self.example_data, DictSupplementaryFileContainer())
31+
self.client = Client(app)
32+
33+
def test_multiple_global_asset_ids_returns_matching_results(self) -> None:
34+
aas_list = [obj for obj in self.example_data if isinstance(obj, model.AssetAdministrationShell)]
35+
known_id = aas_list[0].asset_information.global_asset_id
36+
unknown_id = "http://example.org/nonexistent_asset"
37+
id1 = _encode_asset_id("globalAssetId", known_id)
38+
id2 = _encode_asset_id("globalAssetId", unknown_id)
39+
response = self.client.get(f"{BASE_PATH}/shells?assetIds={id1}&assetIds={id2}")
40+
self.assertEqual(200, response.status_code)
41+
result = json.loads(response.data)
42+
returned_ids = [r["id"] for r in result]
43+
self.assertIn(aas_list[0].id, returned_ids)

0 commit comments

Comments
 (0)