Skip to content

Commit 56fa2f7

Browse files
catch error in API display and api search with type_tools
1 parent f4c90ab commit 56fa2f7

File tree

6 files changed

+1464
-1011
lines changed

6 files changed

+1464
-1011
lines changed

openatlas/api/endpoints/file.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from openatlas.api.resources.api_entity import ApiEntity
1111
from openatlas.api.resources.database_mapper import get_links_by_id_network
1212
from openatlas.api.resources.error import (
13-
DisplayFileNotFoundError, FileIdNotInteger, NoLicenseError, NotPublicError)
13+
DisplayFileNotFoundError, EntityNotAFileError, FileIdNotInteger,
14+
NoLicenseError, NotPublicError)
1415
from openatlas.api.resources.parser import files, image
1516
from openatlas.api.resources.resolve_endpoints import download
1617
from openatlas.api.resources.templates import licensed_file_template
@@ -31,6 +32,8 @@ def get(filename: str) -> Response:
3132
except ValueError:
3233
raise FileIdNotInteger
3334
entity = ApiEntity.get_by_id(id_, types=True)
35+
if entity.class_.group.get('name') != 'file':
36+
raise EntityNotAFileError
3437
if not entity.public:
3538
raise NotPublicError
3639
if not get_license_name(entity):

openatlas/api/formats/presentation_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_presentation_references(
143143
references = []
144144
check_for_duplicates: dict[int, str] = defaultdict(str)
145145
for link in links_inverse:
146-
if link.domain.class_.group['name'] != 'reference' \
146+
if link.domain.class_.group.get('name') != 'reference' \
147147
or link.range.id not in entity_ids \
148148
or check_for_duplicates[link.domain.id] == link.description:
149149
continue

0 commit comments

Comments
 (0)