mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-18 08:02:59 +00:00
Compare commits
2 Commits
65d2ff3751
...
7f95c76c18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f95c76c18 | ||
|
|
bd124596be |
@@ -254,7 +254,7 @@ class WebInterfaceError:
|
||||
exception_name = type(exception).__name__
|
||||
|
||||
if "Config" in exception_name:
|
||||
return ErrorCode.CONFIG_SAVE_FAILED
|
||||
return ErrorCode.CONFIG_LOAD_FAILED
|
||||
elif "Plugin" in exception_name:
|
||||
return ErrorCode.PLUGIN_LOAD_FAILED
|
||||
elif "Permission" in exception_name or "Access" in exception_name:
|
||||
|
||||
@@ -17,6 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
# Import new infrastructure
|
||||
from src.web_interface.api_helpers import success_response, error_response, validate_request_json
|
||||
from src.web_interface.errors import ErrorCode
|
||||
from src.exceptions import ConfigError
|
||||
from src.plugin_system.operation_types import OperationType
|
||||
from src.web_interface.logging_config import log_plugin_operation, log_config_change
|
||||
from src.web_interface.validators import (
|
||||
@@ -440,32 +441,18 @@ def get_dim_schedule_config():
|
||||
})
|
||||
|
||||
return success_response(data=dim_schedule_config)
|
||||
except FileNotFoundError as e:
|
||||
logger.error(f"[DIM SCHEDULE] Config file not found: {e}", exc_info=True)
|
||||
except ConfigError as e:
|
||||
logger.error(f"[DIM SCHEDULE] Config error: {e}", exc_info=True)
|
||||
return error_response(
|
||||
ErrorCode.CONFIG_LOAD_FAILED,
|
||||
"Configuration file not found",
|
||||
status_code=500
|
||||
)
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"[DIM SCHEDULE] Invalid JSON in config file: {e}", exc_info=True)
|
||||
return error_response(
|
||||
ErrorCode.CONFIG_LOAD_FAILED,
|
||||
"Configuration file contains invalid JSON",
|
||||
status_code=500
|
||||
)
|
||||
except (IOError, OSError) as e:
|
||||
logger.error(f"[DIM SCHEDULE] Error reading config file: {e}", exc_info=True)
|
||||
return error_response(
|
||||
ErrorCode.CONFIG_LOAD_FAILED,
|
||||
f"Error reading configuration file: {str(e)}",
|
||||
"Configuration file not found or invalid",
|
||||
status_code=500
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"[DIM SCHEDULE] Unexpected error loading config: {e}", exc_info=True)
|
||||
return error_response(
|
||||
ErrorCode.CONFIG_LOAD_FAILED,
|
||||
f"Unexpected error loading dim schedule configuration: {str(e)}",
|
||||
"Unexpected error loading dim schedule configuration",
|
||||
status_code=500
|
||||
)
|
||||
|
||||
@@ -654,10 +641,6 @@ def save_main_config():
|
||||
if not data:
|
||||
return jsonify({'status': 'error', 'message': 'No data provided'}), 400
|
||||
|
||||
logger.error(f"DEBUG: save_main_config received data: {data}")
|
||||
logger.error(f"DEBUG: Content-Type header: {request.content_type}")
|
||||
logger.error(f"DEBUG: Headers: {dict(request.headers)}")
|
||||
|
||||
# Merge with existing config (similar to original implementation)
|
||||
current_config = api_v3.config_manager.load_config()
|
||||
|
||||
@@ -1012,7 +995,6 @@ def save_raw_main_config():
|
||||
except json.JSONDecodeError as e:
|
||||
return jsonify({'status': 'error', 'message': f'Invalid JSON: {str(e)}'}), 400
|
||||
except Exception as e:
|
||||
from src.exceptions import ConfigError
|
||||
logger.exception("[RawConfig] Failed to save raw main config")
|
||||
if isinstance(e, ConfigError):
|
||||
return error_response(
|
||||
@@ -1051,7 +1033,6 @@ def save_raw_secrets_config():
|
||||
except json.JSONDecodeError as e:
|
||||
return jsonify({'status': 'error', 'message': f'Invalid JSON: {str(e)}'}), 400
|
||||
except Exception as e:
|
||||
from src.exceptions import ConfigError
|
||||
logger.exception("[RawSecrets] Failed to save raw secrets config")
|
||||
if isinstance(e, ConfigError):
|
||||
return error_response(
|
||||
@@ -2738,8 +2719,8 @@ def update_plugin():
|
||||
}
|
||||
)
|
||||
|
||||
logger.exception("[PluginUpdate] Update failed for %s: %s", plugin_id, error_msg)
|
||||
|
||||
logger.error("[PluginUpdate] Update failed for %s: %s", plugin_id, error_msg)
|
||||
|
||||
return error_response(
|
||||
ErrorCode.PLUGIN_UPDATE_FAILED,
|
||||
error_msg,
|
||||
@@ -2748,8 +2729,7 @@ def update_plugin():
|
||||
|
||||
except Exception as e:
|
||||
logger.exception("[PluginUpdate] Exception in update_plugin endpoint")
|
||||
|
||||
logger.exception("[PluginUpdate] Unhandled exception")
|
||||
|
||||
from src.web_interface.errors import WebInterfaceError
|
||||
error = WebInterfaceError.from_exception(e, ErrorCode.PLUGIN_UPDATE_FAILED)
|
||||
if api_v3.operation_history:
|
||||
@@ -4585,15 +4565,17 @@ def save_plugin_config():
|
||||
if not is_valid:
|
||||
# Log validation errors for debugging
|
||||
logger.error(f"Config validation failed for {plugin_id}")
|
||||
logger.error(f"Validation errors: {validation_errors}")
|
||||
logger.error(f"Config that failed: {plugin_config}")
|
||||
logger.error(f"Schema properties: {list(enhanced_schema.get('properties', {}).keys())}")
|
||||
|
||||
# Log raw form data if this was a form submission
|
||||
logger.error(
|
||||
"[PluginConfig] Validation errors: %s | config keys: %s | schema keys: %s",
|
||||
validation_errors,
|
||||
list(plugin_config.keys()),
|
||||
list(enhanced_schema.get('properties', {}).keys()),
|
||||
)
|
||||
if 'application/json' not in (request.content_type or ''):
|
||||
form_data = request.form.to_dict()
|
||||
logger.error("[PluginConfig] Raw form data: %s", json.dumps({k: str(v)[:200] for k, v in form_data.items()}, indent=2))
|
||||
logger.error("[PluginConfig] Parsed config: %s", json.dumps(plugin_config, indent=2, default=str))
|
||||
logger.error(
|
||||
"[PluginConfig] Form field keys: %s",
|
||||
list(request.form.keys()),
|
||||
)
|
||||
return error_response(
|
||||
ErrorCode.CONFIG_VALIDATION_FAILED,
|
||||
'Configuration validation failed',
|
||||
|
||||
Reference in New Issue
Block a user