mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-06-15 17:38:36 +00:00
feat: add error detection, monitoring, and code quality improvements (#223)
* feat: add error detection, monitoring, and code quality improvements This comprehensive update addresses automatic error detection, code quality, and plugin development experience: ## Error Detection & Monitoring - Add ErrorAggregator service for centralized error tracking - Add pattern detection for recurring errors (5+ in 60 min) - Add error dashboard API endpoints (/api/v3/errors/*) - Integrate error recording into plugin executor ## Code Quality - Remove 10 silent `except: pass` blocks in sports.py and football.py - Remove hardcoded debug log paths - Add pre-commit hooks to prevent future bare except clauses ## Validation & Type Safety - Add warnings when plugins lack config_schema.json - Add config key collision detection for plugins - Improve type coercion logging in BasePlugin ## Testing - Add test_config_validation_edge_cases.py - Add test_plugin_loading_failures.py - Add test_error_aggregator.py ## Documentation - Add PLUGIN_ERROR_HANDLING.md guide - Add CONFIG_DEBUGGING.md guide Note: GitHub Actions CI workflow is available in the plan but requires workflow scope to push. Add .github/workflows/ci.yml manually. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address code review issues - Fix GitHub issues URL in CONFIG_DEBUGGING.md - Use RLock in error_aggregator.py to prevent deadlock in export_to_file - Distinguish missing vs invalid schema files in plugin_manager.py - Add assertions to test_null_value_for_required_field test - Remove unused initial_count variable in test_plugin_load_error_recorded - Add validation for max_age_hours in clear_old_errors API endpoint Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Chuck <chuck@example.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -445,3 +445,62 @@ class SchemaManager:
|
||||
replace_none_with_defaults(merged, defaults)
|
||||
return merged
|
||||
|
||||
def detect_config_key_collisions(
|
||||
self,
|
||||
plugin_ids: List[str]
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Detect config key collisions between plugins.
|
||||
|
||||
Checks for:
|
||||
1. Plugin IDs that collide with reserved system config keys
|
||||
2. Plugin IDs that might cause confusion or conflicts
|
||||
|
||||
Args:
|
||||
plugin_ids: List of plugin identifiers to check
|
||||
|
||||
Returns:
|
||||
List of collision warnings, each containing:
|
||||
- type: 'reserved_key_collision' or 'case_collision'
|
||||
- plugin_id: The plugin ID involved
|
||||
- message: Human-readable warning message
|
||||
"""
|
||||
collisions = []
|
||||
|
||||
# Reserved top-level config keys that plugins should not use as IDs
|
||||
reserved_keys = {
|
||||
'display', 'schedule', 'timezone', 'plugin_system',
|
||||
'display_modes', 'system', 'hardware', 'debug',
|
||||
'log_level', 'emulator', 'web_interface'
|
||||
}
|
||||
|
||||
# Track plugin IDs for case collision detection
|
||||
lowercase_ids: Dict[str, str] = {}
|
||||
|
||||
for plugin_id in plugin_ids:
|
||||
# Check reserved key collision
|
||||
if plugin_id.lower() in {k.lower() for k in reserved_keys}:
|
||||
collisions.append({
|
||||
"type": "reserved_key_collision",
|
||||
"plugin_id": plugin_id,
|
||||
"message": f"Plugin ID '{plugin_id}' conflicts with reserved config key. "
|
||||
f"This may cause configuration issues."
|
||||
})
|
||||
|
||||
# Check for case-insensitive collisions between plugins
|
||||
lower_id = plugin_id.lower()
|
||||
if lower_id in lowercase_ids:
|
||||
existing_id = lowercase_ids[lower_id]
|
||||
if existing_id != plugin_id:
|
||||
collisions.append({
|
||||
"type": "case_collision",
|
||||
"plugin_id": plugin_id,
|
||||
"conflicting_id": existing_id,
|
||||
"message": f"Plugin ID '{plugin_id}' may conflict with '{existing_id}' "
|
||||
f"on case-insensitive file systems."
|
||||
})
|
||||
else:
|
||||
lowercase_ids[lower_id] = plugin_id
|
||||
|
||||
return collisions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user