From 4b0f3e1ffc3c26c1e69358f573dc99d7f33a0099 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 28 Jun 2022 20:34:47 +0200 Subject: [PATCH] feat(api): api-v1 handle wrong projectKey --- ee/api/routers/subs/v1_api_ee.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ee/api/routers/subs/v1_api_ee.py b/ee/api/routers/subs/v1_api_ee.py index b402cc051..a4706ff5a 100644 --- a/ee/api/routers/subs/v1_api_ee.py +++ b/ee/api/routers/subs/v1_api_ee.py @@ -20,12 +20,16 @@ def get_assist_credentials(): @app_apikey.get('/v1/{projectKey}/assist/sessions', tags=["api"]) def get_sessions_live(projectKey: str, userId: str = None, context: schemas.CurrentContext = Depends(OR_context)): - return core.get_sessions_live(projectId=projects.get_internal_project_id(projectKey), - userId=userId, context=context) + projectId = projects.get_internal_project_id(projectKey) + if projectId is None: + return {"errors": ["invalid projectKey"]} + return core.get_sessions_live(projectId=projectId, userId=userId, context=context) @app_apikey.post('/v1/{projectKey}/assist/sessions', tags=["api"]) def sessions_live(projectKey: str, data: schemas.LiveSessionsSearchPayloadSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): - return core.sessions_live(projectId=projects.get_internal_project_id(projectKey), - data=data, context=context) + projectId = projects.get_internal_project_id(projectKey) + if projectId is None: + return {"errors": ["invalid projectKey"]} + return core.sessions_live(projectId=projectId, data=data, context=context)