Skip to content

Commit e37ca7f

Browse files
committed
feat: Bump version to 0.12.2 and standardize API error messages across backend and UI.
1 parent cc93992 commit e37ca7f

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

backend/app/app.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_status():
350350
"proxy_host": PROXY_HOST,
351351
"proxy_port": PROXY_PORT,
352352
"timestamp": datetime.now().isoformat(),
353-
"version": "0.0.9"
353+
"version": "0.12.2"
354354
}
355355

356356
# Add today's request count
@@ -561,7 +561,7 @@ def import_blacklist():
561561

562562
except requests.exceptions.RequestException as e:
563563
logger.error(f"Failed to fetch blacklist from URL {url}: {str(e)}")
564-
return jsonify({"status": "error", "message": f"Failed to fetch from URL: {str(e)}"}), 400
564+
return jsonify({"status": "error", "message": "Failed to fetch from URL"}), 400
565565

566566
# Check if direct content is provided
567567
elif 'content' in data:
@@ -693,7 +693,7 @@ def import_blacklist():
693693

694694
except Exception as e:
695695
logger.error(f"Error during blacklist import: {str(e)}")
696-
return jsonify({"status": "error", "message": f"Import failed: {str(e)}"}), 500
696+
return jsonify({"status": "error", "message": "Import operation failed"}), 500
697697

698698
@app.route('/api/ip-blacklist/import', methods=['POST'])
699699
@auth.login_required
@@ -712,7 +712,7 @@ def import_ip_blacklist():
712712

713713
except Exception as e:
714714
logger.error(f"Error during IP blacklist import: {str(e)}")
715-
return jsonify({"status": "error", "message": f"Import failed: {str(e)}"}), 500
715+
return jsonify({"status": "error", "message": "Import operation failed"}), 500
716716

717717
@app.route('/api/domain-blacklist/import', methods=['POST'])
718718
@auth.login_required
@@ -731,7 +731,7 @@ def import_domain_blacklist():
731731

732732
except Exception as e:
733733
logger.error(f"Error during domain blacklist import: {str(e)}")
734-
return jsonify({"status": "error", "message": f"Import failed: {str(e)}"}), 500
734+
return jsonify({"status": "error", "message": "Import operation failed"}), 500
735735

736736
# Helper functions
737737
def update_ip_blacklist():
@@ -781,8 +781,8 @@ def clear_logs():
781781
logger.info("All logs cleared successfully")
782782
return jsonify({"status": "success", "message": "All logs cleared successfully"})
783783
except Exception as e:
784-
logger.error(f"Error clearing logs: {str(e)}")
785-
return jsonify({"status": "error", "message": f"Error clearing logs: {str(e)}"}), 500
784+
logger.error("An error occurred while clearing logs")
785+
return jsonify({"status": "error", "message": "An error occurred while clearing logs"}), 500
786786

787787
@app.route('/api/maintenance/reload-config', methods=['POST'])
788788
@auth.login_required
@@ -795,8 +795,8 @@ def reload_proxy_config():
795795
else:
796796
return jsonify({"status": "error", "message": "Failed to reload proxy configuration"}), 500
797797
except Exception as e:
798-
logger.error(f"Error reloading proxy configuration: {str(e)}")
799-
return jsonify({"status": "error", "message": f"Error reloading proxy configuration: {str(e)}"}), 500
798+
logger.error("An error occurred while reloading proxy configuration")
799+
return jsonify({"status": "error", "message": "An error occurred while reloading proxy configuration"}), 500
800800

801801
def update_domain_blacklist():
802802
"""Update the domain blacklist file"""
@@ -2641,11 +2641,11 @@ def optimize_cache():
26412641
}
26422642
})
26432643
except ValueError as e:
2644-
logger.error(f"Validation error: {str(e)}")
2645-
return jsonify({"status": "error", "message": f"Validation error: {str(e)}"}), 400
2644+
logger.error("Validation error occurred")
2645+
return jsonify({"status": "error", "message": "Validation error occurred"}), 400
26462646
except Exception as e:
2647-
logger.error(f"Error optimizing cache: {str(e)}")
2648-
return jsonify({"status": "error", "message": f"Error optimizing cache: {str(e)}"}), 500
2647+
logger.error("An error occurred while optimizing cache")
2648+
return jsonify({"status": "error", "message": "An error occurred while optimizing cache"}), 500
26492649

26502650
# Health check endpoint for container orchestration
26512651
@app.route('/health', methods=['GET'])
@@ -2764,8 +2764,8 @@ def clear_old_logs():
27642764
"deleted_count": count_to_delete
27652765
})
27662766
except Exception as e:
2767-
logger.error(f"Error clearing old logs: {str(e)}")
2768-
return jsonify({"status": "error", "message": f"Error clearing old logs: {str(e)}"}), 500
2767+
logger.error("An error occurred while clearing old logs")
2768+
return jsonify({"status": "error", "message": "An error occurred while clearing old logs"}), 500
27692769

27702770
@app.route('/api/database/size', methods=['GET'])
27712771
@auth.login_required
@@ -2800,8 +2800,8 @@ def get_database_size():
28002800
"message": f"Database file not found at {db_path}"
28012801
}), 404
28022802
except Exception as e:
2803-
logger.error(f"Error getting database size: {str(e)}")
2804-
return jsonify({"status": "error", "message": f"Error getting database size: {str(e)}"}), 500
2803+
logger.error("An error occurred while getting database size")
2804+
return jsonify({"status": "error", "message": "An error occurred while getting database size"}), 500
28052805

28062806
@app.route('/api/database/optimize', methods=['POST'])
28072807
@auth.login_required
@@ -2896,8 +2896,8 @@ def export_database():
28962896
"data": export_data
28972897
})
28982898
except Exception as e:
2899-
logger.error(f"Error exporting database: {str(e)}")
2900-
return jsonify({"status": "error", "message": f"Error exporting database: {str(e)}"}), 500
2899+
logger.error("An error occurred while exporting database")
2900+
return jsonify({"status": "error", "message": "An error occurred while exporting database"}), 500
29012901

29022902
@app.route('/api/security/scan', methods=['POST'])
29032903
@auth.login_required
@@ -3016,8 +3016,8 @@ def client_statistics():
30163016
return jsonify({"status": "success", "data": data})
30173017

30183018
except Exception as e:
3019-
logger.error(f"Error fetching client statistics: {str(e)}")
3020-
return jsonify({"status": "error", "message": f"Error fetching client statistics: {str(e)}"}), 500
3019+
logger.error("An error occurred while fetching client statistics")
3020+
return jsonify({"status": "error", "message": "An error occurred while fetching client statistics"}), 500
30213021

30223022
@app.route('/api/domains/statistics', methods=['GET'])
30233023
@auth.login_required
@@ -3080,8 +3080,8 @@ def domain_statistics():
30803080
return jsonify({"status": "success", "data": data})
30813081

30823082
except Exception as e:
3083-
logger.error(f"Error fetching domain statistics: {str(e)}")
3084-
return jsonify({"status": "error", "message": f"Error fetching domain statistics: {str(e)}"}), 500
3083+
logger.error("An error occurred while fetching domain statistics")
3084+
return jsonify({"status": "error", "message": "An error occurred while fetching domain statistics"}), 500
30853085

30863086
@app.route('/api/database/reset', methods=['POST'])
30873087
@auth.login_required
@@ -3122,14 +3122,14 @@ def reset_database():
31223122

31233123
return jsonify({"status": "success", "message": "Database reset successfully. Please refresh your UI."}), 200
31243124
except Exception as e:
3125-
logger.error(f"Error resetting database: {str(e)}")
3125+
logger.error("An error occurred while resetting database")
31263126
# Attempt to re-initialize DB even on error to prevent a broken state
31273127
try:
31283128
init_db()
31293129
logger.warning("Attempted to re-initialize database after reset error to prevent broken state.")
31303130
except Exception as init_e:
31313131
logger.error(f"Failed to re-initialize database after reset error: {str(init_e)}")
3132-
return jsonify({"status": "error", "message": f"Error resetting database: {str(e)}"}), 500
3132+
return jsonify({"status": "error", "message": "An error occurred while resetting database"}), 500
31333133

31343134
@app.route('/api/database/stats', methods=['GET'])
31353135
@auth.login_required
@@ -3184,5 +3184,5 @@ def get_database_stats():
31843184

31853185
return jsonify({"status": "success", "data": stats})
31863186
except Exception as e:
3187-
logger.error(f"Error fetching database stats: {str(e)}")
3188-
return jsonify({"status": "error", "message": f"Error fetching database stats: {str(e)}"}), 500
3187+
logger.error("An error occurred while fetching database statistics")
3188+
return jsonify({"status": "error", "message": "An error occurred while fetching database statistics"}), 500

backend/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ gunicorn==23.0.0
88
sqlalchemy==2.0.36
99
python-dotenv==1.0.1
1010
pytz==2024.2
11-
werkzeug==3.0.6
11+
werkzeug==3.1.3
1212
markupsafe==2.1.5

ui/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def check_backend():
275275
else:
276276
return jsonify({"status": "unavailable", "message": f"Backend service returned status {resp.status_code}"}), 503
277277
except requests.RequestException as e:
278-
return jsonify({"status": "unavailable", "message": f"Backend service is not available: {str(e)}"}), 503
278+
return jsonify({"status": "unavailable", "message": "Backend service is temporarily unavailable"}), 503
279279

280280
@app.route('/api/clients/statistics', methods=['GET'])
281281
@basic_auth.required
@@ -303,7 +303,7 @@ def client_statistics():
303303

304304
except requests.exceptions.RequestException as e:
305305
app.logger.error(f"Request to backend failed for {url}: {e}")
306-
return jsonify({"status": "error", "message": str(e)}), 503
306+
return jsonify({"status": "error", "message": "An error occurred"}), 503
307307

308308
@app.route('/api/domains/statistics', methods=['GET'])
309309
@basic_auth.required

ui/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Flask==3.0.3
22
requests==2.32.4
33
python-dotenv==1.0.1
44
flask-basicauth==0.2.0
5-
werkzeug==3.0.6
5+
werkzeug==3.1.3
66
markupsafe==2.1.5

ui/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ <h5 class="modal-title" id="aboutModalLabel">About Secure Proxy</h5>
856856
<div class="modal-body text-center">
857857
<i class="fas fa-shield-alt fa-4x mb-3" style="color: var(--primary-color);"></i>
858858
<h4>Secure Proxy</h4>
859-
<p class="text-muted">Version 0.0.9</p>
859+
<p class="text-muted">Version 0.12.2</p>
860860
<p>A modern web interface for managing Squid Proxy with enhanced security features.</p>
861861

862862
<div class="mt-4 mb-3">

0 commit comments

Comments
 (0)