From 610d4a9f40fc0c450ddc3b5a48e4028ff18d199f Mon Sep 17 00:00:00 2001 From: jdorsch Date: Tue, 13 Feb 2024 11:19:57 +0100 Subject: [PATCH 1/2] fixed error on /compute/post when uploading a file --- CHANGELOG.md | 2 ++ src/compute/compute.py | 6 ++++++ src/status/status.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d808a0ed..0f02f65e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed demo images dependency declarations preventing docker-compose to build successfully. +- Fixed check when submitted an empty batch file on `POST /compute/jobs/upload` +- Fixed error message when `GET /status/systems` encounters error in one filesystem ## [1.14.0] diff --git a/src/compute/compute.py b/src/compute/compute.py index b96dc808..101728d7 100644 --- a/src/compute/compute.py +++ b/src/compute/compute.py @@ -401,6 +401,12 @@ def submit_job_upload(): app.logger.error('No batch file selected') error = jsonify(description="Failed to submit job file", error='No batch file selected') return error, 400 + + if job_file['content'] == '': + app.logger.error('Batch file is empty') + error = jsonify(description="Failed to submit job file", error='Batch file is empty') + return error, 400 + except RequestEntityTooLarge as re: app.logger.error(re.description) diff --git a/src/status/status.py b/src/status/status.py index 6d9a17f0..670c47a4 100644 --- a/src/status/status.py +++ b/src/status/status.py @@ -321,10 +321,10 @@ def status_systems(): # if status == -5: reason = res["reason"] - ret_dict={"system":machinename, "status":"not available", "description": f"Error on JWT token: {reason}"} + ret_dict={"system": system, "status":"not available", "description": f"Error on JWT token: {reason}"} if status == -4: filesystem = res["filesystem"] - ret_dict={"system":machinename, "status":"not available", "description": f"Filesystem {filesystem} is not available"} + ret_dict={"system": system, "status":"not available", "description": f"Filesystem {filesystem} is not available"} elif status == -2: ret_dict = {"system": system, "status": "not available", "description": "System down"} elif status == -1: From fddfd3b6c84fd0597739ef01f2b99eb093bd9578 Mon Sep 17 00:00:00 2001 From: jdorsch Date: Tue, 13 Feb 2024 12:31:41 +0100 Subject: [PATCH 2/2] added decode to check file is empty --- src/compute/compute.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compute/compute.py b/src/compute/compute.py index 101728d7..faccf0b8 100644 --- a/src/compute/compute.py +++ b/src/compute/compute.py @@ -402,7 +402,8 @@ def submit_job_upload(): error = jsonify(description="Failed to submit job file", error='No batch file selected') return error, 400 - if job_file['content'] == '': + # decoding content, since from read() method it returns binary encoding + if job_file['content'].decode() == '': app.logger.error('Batch file is empty') error = jsonify(description="Failed to submit job file", error='Batch file is empty') return error, 400