mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-01 07:42:19 -07:00
Fixes for Coderabbit review
This commit is contained in:
@@ -7,6 +7,7 @@ import os
|
||||
from flask import Flask, request, jsonify, Response
|
||||
from models.device_instance import DeviceInstance # noqa: E402
|
||||
from flask_cors import CORS
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
# Register NetAlertX directories
|
||||
INSTALL_PATH = os.getenv("NETALERTX_APP", "/app")
|
||||
@@ -105,6 +106,8 @@ app = Flask(__name__)
|
||||
@app.errorhandler(Exception)
|
||||
def handle_500_error(e):
|
||||
"""Global error handler for uncaught exceptions."""
|
||||
if isinstance(e, HTTPException):
|
||||
return e
|
||||
mylog("none", [f"[API] Uncaught exception: {e}"])
|
||||
return jsonify({
|
||||
"success": False,
|
||||
|
||||
@@ -679,6 +679,7 @@ class CreateEventRequest(BaseModel):
|
||||
# =============================================================================
|
||||
# SESSIONS SCHEMAS
|
||||
# =============================================================================
|
||||
class SessionInfo(BaseModel):
|
||||
"""Session information."""
|
||||
model_config = ConfigDict(
|
||||
extra="allow",
|
||||
|
||||
@@ -77,7 +77,7 @@ def generate_openapi_spec(
|
||||
# Apply default disabled tools from setting `MCP_DISABLED_TOOLS`, env var, or hard-coded defaults
|
||||
# Format: comma-separated operation IDs, e.g. "dbquery_read,dbquery_write"
|
||||
try:
|
||||
disabled_env = ""
|
||||
disabled_env = None
|
||||
# Prefer setting from app.conf/settings when available
|
||||
try:
|
||||
from helper import get_setting_value
|
||||
@@ -88,9 +88,9 @@ def generate_openapi_spec(
|
||||
# If helper is unavailable, fall back to environment
|
||||
pass
|
||||
|
||||
if disabled_env is None:
|
||||
if not disabled_env:
|
||||
env_val = os.getenv("MCP_DISABLED_TOOLS")
|
||||
if env_val is not None:
|
||||
if env_val:
|
||||
disabled_env = env_val.strip()
|
||||
|
||||
# If still not set, apply safe hard-coded defaults
|
||||
|
||||
Reference in New Issue
Block a user