From 6fc12d50cb4eeca3348a2578addce2b0a63ed3ab Mon Sep 17 00:00:00 2001 From: jChenvan <188939308+jChenvan@users.noreply.github.com> Date: Sat, 6 Sep 2025 10:30:40 -0400 Subject: [PATCH] Handle missing fields for adding source --- docker/ploughshares/app.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docker/ploughshares/app.py b/docker/ploughshares/app.py index 884592c..1feb668 100644 --- a/docker/ploughshares/app.py +++ b/docker/ploughshares/app.py @@ -1068,12 +1068,6 @@ def create_source(): """API endpoint to create a source""" data = request.form.to_dict() - # Validate required fields - required_fields = ['title', 'link', 'type'] - for field in required_fields: - if field not in data or not data[field]: - return jsonify({"error": f"Missing required field: {field}"}), 400 - conn = get_db_connection() if conn is None: return jsonify({"error": "Database connection error"}), 500 @@ -1089,9 +1083,9 @@ def create_source(): ) RETURNING src_id """, { - 'title': data['title'], - 'link': data['link'], - 'type': data['type'] + 'title': data['title'] if ('title' in data) else "", + 'link': data['link'] if ('link' in data) else "", + 'type': data['type'] if ('link' in data) else "" } ) result = cur.fetchone()