Skip to content

Commit 25b09b0

Browse files
authored
Bugfix: accessing unknown request must return a 404 error (#92)
1 parent 879a897 commit 25b09b0

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

cads_catalogue_api_service/vocabularies.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,25 @@ def query_licence(
9696
cads_catalogue.database.Licence.portal,
9797
)
9898
query = query.filter(cads_catalogue.database.Licence.licence_uid == licence_uid)
99-
try:
100-
results = (
101-
query.group_by(
102-
cads_catalogue.database.Licence.licence_uid,
103-
cads_catalogue.database.Licence.title,
104-
cads_catalogue.database.Licence.md_filename,
105-
cads_catalogue.database.Licence.download_filename,
106-
cads_catalogue.database.Licence.revision,
107-
cads_catalogue.database.Licence.scope,
108-
cads_catalogue.database.Licence.portal,
109-
)
110-
.order_by(sa.desc("revision"))
111-
.first()
99+
result = (
100+
query.group_by(
101+
cads_catalogue.database.Licence.licence_uid,
102+
cads_catalogue.database.Licence.title,
103+
cads_catalogue.database.Licence.md_filename,
104+
cads_catalogue.database.Licence.download_filename,
105+
cads_catalogue.database.Licence.revision,
106+
cads_catalogue.database.Licence.scope,
107+
cads_catalogue.database.Licence.portal,
112108
)
113-
except sa.exc.NoResultFound as exc:
109+
.order_by(sa.desc("revision"))
110+
.first()
111+
)
112+
if not result:
114113
raise fastapi.HTTPException(
115114
status_code=fastapi.status.HTTP_404_NOT_FOUND,
116115
detail=f"licence {licence_uid} not found",
117-
) from exc
118-
return results # type: ignore
116+
)
117+
return result # type: ignore
119118

120119

121120
def query_keywords(

0 commit comments

Comments
 (0)