From e9eaa511730bf0bb4034583053aa0ee847f7414e Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 14 Nov 2022 17:14:24 +0100 Subject: [PATCH 1/4] chore(build): changed script --- ee/api/.gitignore | 2 +- ee/api/clean.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/api/.gitignore b/ee/api/.gitignore index 4860784c3..ee23eb7ff 100644 --- a/ee/api/.gitignore +++ b/ee/api/.gitignore @@ -248,7 +248,7 @@ Pipfile /routers/core.py /routers/crons/core_crons.py /db_changes.sql -/Dockerfile.bundle +/Dockerfile_bundle /entrypoint.bundle.sh /chalicelib/core/heatmaps.py /schemas.py diff --git a/ee/api/clean.sh b/ee/api/clean.sh index 083e72cde..314321b83 100755 --- a/ee/api/clean.sh +++ b/ee/api/clean.sh @@ -70,7 +70,7 @@ rm -rf ./routers/base.py rm -rf ./routers/core.py rm -rf ./routers/crons/core_crons.py rm -rf ./db_changes.sql -rm -rf ./Dockerfile.bundle +rm -rf ./Dockerfile_bundle rm -rf ./entrypoint.bundle.sh rm -rf ./chalicelib/core/heatmaps.py rm -rf ./schemas.py From 731f47d9395d3f51a27bbffe0b72c8e885065a41 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 15 Nov 2022 14:02:29 +0100 Subject: [PATCH 2/4] chore(chalice): return error if unprocessed file is huge chore(chalice): fixed add webhook --- api/chalicelib/core/assist.py | 10 ++++++---- api/routers/core.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/chalicelib/core/assist.py b/api/chalicelib/core/assist.py index 0a5e5e59d..7fd68e029 100644 --- a/api/chalicelib/core/assist.py +++ b/api/chalicelib/core/assist.py @@ -1,5 +1,5 @@ from os import access, R_OK -from os.path import exists as path_exists +from os.path import exists as path_exists, getsize import jwt import requests @@ -207,9 +207,11 @@ def get_raw_mob_by_id(project_id, session_id): path_to_file = efs_path + "/" + __get_mob_path(project_id=project_id, session_id=session_id) if path_exists(path_to_file): if not access(path_to_file, R_OK): - raise HTTPException(400, f"Replay file found under: {efs_path};" - f" but it is not readable, please check permissions") - + raise HTTPException(400, f"Replay file found under: {efs_path};" + + f" but it is not readable, please check permissions") + # getsize return size in bytes, UNPROCESSED_MAX_SIZE is in Kb + if (getsize(path_to_file) / 1000) >= config("UNPROCESSED_MAX_SIZE", cast=int, default=200 * 1000): + raise HTTPException(413, "Replay file too large") return path_to_file return None diff --git a/api/routers/core.py b/api/routers/core.py index 9a0032329..76383668d 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -867,7 +867,7 @@ def delete_slack_integration(integrationId: int, context: schemas.CurrentContext return webhook.delete(context.tenant_id, integrationId) -@app.post('/webhooks', tags=["webhooks"]) +@app.put('/webhooks', tags=["webhooks"]) def add_edit_webhook(data: schemas.CreateEditWebhookSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): return {"data": webhook.add_edit(tenant_id=context.tenant_id, data=data.dict(), replace_none=True)} From d89ced3579af44c848e0cd7e677d0ef05ce2ed62 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 15 Nov 2022 14:10:36 +0100 Subject: [PATCH 3/4] chore(chalice): support old search --- api/routers/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/routers/core.py b/api/routers/core.py index 76383668d..80f2b6296 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -49,6 +49,7 @@ def login(data: schemas.UserLoginSchema = Body(...)): @app.post('/{projectId}/sessions/search', tags=["sessions"]) +@app.post('/{projectId}/sessions/search2', tags=["sessions"]) def sessions_search(projectId: int, data: schemas.FlatSessionsSearchPayloadSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): data = sessions.search_sessions(data=data, project_id=projectId, user_id=context.user_id) From e6b883572808f0d7d0b166ddceb2812202d6788e Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 15 Nov 2022 15:23:32 +0100 Subject: [PATCH 4/4] chore(chalice): enhanced sourcemaps to handle incorrect frames --- api/chalicelib/core/sourcemaps.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/api/chalicelib/core/sourcemaps.py b/api/chalicelib/core/sourcemaps.py index 886198e35..921649d97 100644 --- a/api/chalicelib/core/sourcemaps.py +++ b/api/chalicelib/core/sourcemaps.py @@ -54,7 +54,8 @@ def __frame_is_valid(f): def __format_frame(f): f["context"] = [] # no context by default - if "source" in f: f.pop("source") + if "source" in f: + f.pop("source") url = f.pop("fileName") f["absPath"] = url f["filename"] = urlparse(url).path @@ -74,8 +75,13 @@ def format_payload(p, truncate_to_first=False): def url_exists(url): - r = requests.head(url, allow_redirects=False) - return r.status_code == 200 and r.headers.get("Content-Type") != "text/html" + try: + r = requests.head(url, allow_redirects=False) + return r.status_code == 200 and r.headers.get("Content-Type") != "text/html" + except Exception as e: + print(f"!! Issue checking if URL exists: {url}") + print(e) + return False def get_traces_group(project_id, payload): @@ -97,8 +103,8 @@ def get_traces_group(project_id, payload): continue if key not in payloads: - file_exists_in_bucket = s3.exists(config('sourcemaps_bucket'), key) - if not file_exists_in_bucket: + file_exists_in_bucket = len(file_url) > 0 and s3.exists(config('sourcemaps_bucket'), key) + if len(file_url) > 0 and not file_exists_in_bucket: print(f"{u['absPath']} sourcemap (key '{key}') doesn't exist in S3 looking in server") if not file_url.endswith(".map"): file_url += '.map'