Handle missing fields for adding source
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
4cdd0f9aaa
commit
6fc12d50cb
|
@ -1068,12 +1068,6 @@ def create_source():
|
||||||
"""API endpoint to create a source"""
|
"""API endpoint to create a source"""
|
||||||
data = request.form.to_dict()
|
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()
|
conn = get_db_connection()
|
||||||
if conn is None:
|
if conn is None:
|
||||||
return jsonify({"error": "Database connection error"}), 500
|
return jsonify({"error": "Database connection error"}), 500
|
||||||
|
@ -1089,9 +1083,9 @@ def create_source():
|
||||||
) RETURNING src_id
|
) RETURNING src_id
|
||||||
""",
|
""",
|
||||||
{
|
{
|
||||||
'title': data['title'],
|
'title': data['title'] if ('title' in data) else "",
|
||||||
'link': data['link'],
|
'link': data['link'] if ('link' in data) else "",
|
||||||
'type': data['type']
|
'type': data['type'] if ('link' in data) else ""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
result = cur.fetchone()
|
result = cur.fetchone()
|
||||||
|
|
Loading…
Reference in New Issue