diff --git a/app.py b/app.py index 8acdd07..df59a52 100644 --- a/app.py +++ b/app.py @@ -181,7 +181,7 @@ def api_network(): try: return jsonify(json.loads(raw)) except Exception: - pass + logger.error('Failed to parse network_snapshot JSON') return jsonify({'hosts': {}, 'unifi': [], 'updated': None}) @@ -193,7 +193,7 @@ def api_links(): try: return jsonify(json.loads(raw)) except Exception: - pass + logger.error('Failed to parse link_stats JSON') return jsonify({'hosts': {}, 'updated': None}) @@ -261,9 +261,12 @@ def api_diagnose_start(): """Start a link diagnostic job. Returns {job_id}.""" data = request.get_json(silent=True) or {} switch_name = (data.get('switch_name') or '').strip() - port_idx = data.get('port_idx') + try: + port_idx = int(data.get('port_idx')) + except (TypeError, ValueError): + return jsonify({'error': 'port_idx must be an integer'}), 400 - if not switch_name or port_idx is None: + if not switch_name: return jsonify({'error': 'switch_name and port_idx required'}), 400 # Look up switch + port in cached link_stats