-
Notifications
You must be signed in to change notification settings - Fork 5
Centralize configuration through ConfigManager #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: garland3 <[email protected]>
Co-authored-by: garland3 <[email protected]>
Co-authored-by: garland3 <[email protected]>
backend/core/otel_config.py
Outdated
| from modules.config import config_manager | ||
| if config_manager.app_settings.app_log_dir: | ||
| return Path(config_manager.app_settings.app_log_dir) | ||
| except Exception: |
Check notice
Code scanning / CodeQL
Empty except Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 24 days ago
To fix the problem, the except Exception: block should include a logging statement to record that the primary configuration path failed, with the exception details. This ensures that, if there is a problem with the configuration, its nature is not lost, and debugging is easier. The log level should likely be warning, as the program will fallback to a default and continue working, but the failure is noteworthy.
The code change should be in backend/core/otel_config.py, within the _get_logs_dir method. Add a comment explaining the fallback and log the exception (using logging.warning). Since the class handles logging configuration, but may not have been set up yet at this point, basic logging to the root logger is acceptable.
No new imports are needed, as logging is already imported.
-
Copy modified lines R93-R95
| @@ -90,8 +90,9 @@ | ||
| from modules.config import config_manager | ||
| if config_manager.app_settings.app_log_dir: | ||
| return Path(config_manager.app_settings.app_log_dir) | ||
| except Exception: | ||
| pass | ||
| except Exception as e: | ||
| # Could not get log directory from config manager, falling back to default. Log for debugging. | ||
| logging.warning("Failed to get log directory from config manager, falling back to default: %s", e) | ||
| # Fallback: project_root/logs | ||
| project_root = Path(__file__).resolve().parents[2] | ||
| return project_root / "logs" |
- Renamed `modules/config/manager.py` to `modules/config/config_manager.py` - Updated all import statements across the codebase to reflect the new module name - Added `backend/minio-data/` to `.gitignore` for MinIO data storage - Minor formatting fix in `otel_config.py` (added space after `except Exception:`) This change improves module naming clarity and consistency in the config management system.
garland3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some additional changes this looks good.
| modifying the actual environment or configuration files. | ||
| """ | ||
|
|
||
| import pytest |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 24 days ago
To resolve the unused import error, simply remove the line import pytest from the file backend/tests/test_config_manager.py. This will eliminate unnecessary dependency and improve code readability. No other changes are needed, as no features or symbols from pytest are referenced directly in this file.
| @@ -4,7 +4,6 @@ | ||
| modifying the actual environment or configuration files. | ||
| """ | ||
|
|
||
| import pytest | ||
| from pathlib import Path | ||
| from backend.modules.config.config_manager import ( | ||
| ConfigManager, |
Scattered
os.getenv()calls throughout the codebase made configuration hard to understand and maintain. This consolidates all environment variable loading through the existingConfigManager.Changes
Extended AppSettings with previously scattered configuration:
app_config_overrides,app_config_defaults,app_log_direnvironment,runtime_feedback_dirpi_threshold_low/medium/highReplaced direct env access in 8 files:
core/capabilities.py,core/otel_config.py,core/prompt_risk.pyroutes/feedback_routes.py,routes/admin_routes.py,routes/config_routes.pymodules/mcp_tools/client.pyUsage pattern:
All settings now flow through Pydantic's type-validated
AppSettingsinmodules/config/manager.py. Bootstrap fallbacks preserved inotel_config.pyfor early initialization.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.shcurl -LsSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.