Fix Issue 9: Enforce configuration precedence rules

- Established explicit precedence: ENV vars > config.json > defaults
- Updated fastapi_app.py to only sync config.json when ENV var not set
- Added precedence logging to show which source is used
- Documented precedence rules with examples in CONFIGURATION.md

Key principle: ENV variables always take precedence, config.json is
fallback only. This ensures deployment flexibility and clear priority.

All config tests passing (26/26)
This commit is contained in:
2026-01-24 21:23:48 +01:00
parent ed3882991f
commit c4080e4e57
3 changed files with 71 additions and 28 deletions

View File

@@ -224,16 +224,26 @@ For each task completed:
### Architecture Review Findings - Medium Priority Issues
#### Issue 9: Configuration Scattered Across Multiple Sources
#### Issue 9: Configuration Scattered Across Multiple Sources ✅ RESOLVED
- **Locations**:
- `src/config/settings.py` (environment-based settings)
- `data/config.json` (file-based configuration)
- Hardcoded values in multiple service files
- **Problem**: Configuration access is inconsistent - unclear source of truth
- **Impact**: Difficult to trace where values come from, testing complexity
- **Fix Required**: Single configuration source with clear precedence rules
- **Severity**: MEDIUM - Maintenance burden
- `src/config/settings.py` (environment-based settings) - PRIMARY source
- `data/config.json` (file-based configuration) - SECONDARY source
- ✅ Precedence now clearly defined and enforced
- **Problem**: Configuration access was inconsistent with unclear source of truth and precedence
- **Impact**: Difficult to trace where values come from, testing complexity, ENV vars being overridden
- **Fix Applied**:
- **Precedence Established**: ENV vars > config.json > defaults (explicitly enforced)
- Updated `fastapi_app.py` to only sync config.json values if ENV var not set (respects precedence)
- Added precedence logging to show which source is used
- Documented precedence rules with examples in `CONFIGURATION.md`
- **Principle**: ENV variables always take precedence, config.json is fallback only
- **Resolution Date**: January 24, 2026
- **Files Modified**:
- `src/server/fastapi_app.py` - Implemented selective sync with precedence checks
- `docs/CONFIGURATION.md` - Documented precedence rules and examples
- **Architecture Decision**: Settings object (`settings.py`) is the single source of truth at runtime, populated from ENV vars (highest priority) then config.json (fallback)
- **Severity**: MEDIUM - Maintenance burden (FIXED)
#### Issue 10: Inconsistent Error Handling Patterns