fd685e8211
refactor: Remove unused HTTPException imports from routers
...
After removing all try/except blocks that used HTTPException for domain
exception conversion, these imports are no longer needed in the routers.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com >
2026-04-23 16:01:44 +02:00
5480dce221
refactor: Remove duplicate router-level exception helpers
...
All routers now let domain exceptions propagate to the global handlers in main.py
instead of catching and converting them to HTTPException. This eliminates:
- Duplicate exception-to-HTTP-status mappings across 8 routers
- Duplicate helper functions (_bad_gateway, _not_found, _conflict, etc.)
- Inconsistent error response formats
Changes:
- Removed all try/except blocks from routers that catch domain exceptions
- Removed duplicate helper functions from all routers
- Added missing exception handlers to main.py for:
* ActionNameError
* FilterNameError
* JailNameError
* JailNotFoundInConfigError
* FilterInvalidRegexError
- Removed unused imports from affected routers
All domain exceptions now propagate to the single authoritative mapping in
main.py, ensuring consistent error codes, messages, and logging across the API.
Affected routers:
- action_config.py: Removed _action_not_found, _bad_request, _not_found helpers
- bans.py: Removed try/except in ban/unban endpoints
- config_misc.py: Removed try/except blocks
- file_config.py: Removed 6 try/except blocks and _service_unavailable helper
- filter_config.py: Removed try/except blocks
- geo.py: Removed try/except in lookup_ip endpoint
- jail_config.py: Removed try/except blocks
- jails.py: Removed try/except blocks
- server.py: Removed try/except blocks
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com >
2026-04-23 16:00:37 +02:00
b634ce876a
refactor: Extract fail2ban response utilities into shared module
...
Consolidate duplicate _ok(), _to_dict(), ensure_list(), and is_not_found_error()
functions from 6 service modules into a single canonical implementation at
backend/app/utils/fail2ban_response.py.
Changes:
- Create fail2ban_response.py with canonical implementations
- Remove local duplicates from: ban_service, jail_service, config_service,
health_service, server_service, config_file_utils
- Update all imports to use shared module
- Add comprehensive docstrings and examples
- Update Architecture.md and Backend-Development.md documentation
Benefits:
- Single source of truth for response parsing logic
- Eliminates code duplication across service layer
- Improves maintainability and consistency
- Enables centralized bug fixes and improvements
Tests: All 228 service tests passing, no regressions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com >
2026-04-23 15:11:21 +02:00
4c313af1c5
Narrow jail config types with explicit union values
2026-04-21 19:39:36 +02:00
e593498de5
Strengthen setup password validation
...
- Add backend Pydantic password complexity validation for setup
- Update frontend setup page with password rule feedback and strength indicator
- Add/adjust setup API tests for password validation
- Document setup password requirements
- Fix frontend test type annotation issue
2026-04-20 19:23:12 +02:00
01f2e07921
Extract shared raw config file helpers and simplify raw_config_io_service
2026-04-18 20:18:54 +02:00
c1f188643c
Move geo cache commit handling into repository layer
2026-04-18 20:10:05 +02:00
be1d66988f
Document RuntimeState concurrency model and mark task 5 complete
2026-04-18 19:56:41 +02:00
52e08e17a4
Guard geo_service.init_geoip against repeated initialization
2026-04-18 19:54:05 +02:00
99731a9919
Remove empty backend helpers package
2026-04-18 19:50:44 +02:00
db5b4cb77e
Add settings and history archive repository protocols and DI support
2026-04-17 20:54:08 +02:00
7055971163
Harden preview_log path validation and add regression test
2026-04-17 20:37:14 +02:00
5e5d7c34b2
Document task DB access and unify background task DB handling
2026-04-17 17:18:49 +02:00
4754f1407e
Mark task 19 done and centralize map-color thresholds in settings_service
2026-04-17 17:04:09 +02:00
7a1cb0c46c
Extract health-check crash-detection logic into runtime state helper
2026-04-17 16:58:24 +02:00
1e2850a34e
Add async lock protection to geo service cache and mark Task 16 done
2026-04-17 16:51:05 +02:00
04b2e2f700
Add global domain exception handlers in main.py
...
Register consistent HTTP error mappings for common domain exceptions and add regression tests for 404/400/500 handler behavior.
2026-04-17 16:42:18 +02:00
900d111a5d
Refactor geo enrichment into jail_service and mark Task 14 done
2026-04-17 16:36:22 +02:00
487f252a4d
Move history geo enrichment into history service
2026-04-17 16:28:53 +02:00
8c6950afc1
Task 13: move ban_ip, unban_ip, and get_active_bans from jail_service to ban_service and update routers/tests
2026-04-17 16:22:20 +02:00
6e1e3c4546
Remove unused service protocol aliases and use direct service imports
2026-04-17 16:01:27 +02:00
7d16391c6c
Centralise DbDep and mark Task 11 complete
2026-04-17 15:44:13 +02:00
74ff4cb4b8
Remove repository import from setup_utils and move password-hash helper to setup service
2026-04-17 15:38:41 +02:00
58112fb191
Move auth session signing into auth_service.login
2026-04-17 15:33:09 +02:00
33643880ed
Extract fail2ban restart orchestration into jail_service
2026-04-17 15:23:54 +02:00
c21cf82e9e
Refactor map color threshold storage into dedicated settings service
2026-04-17 15:13:07 +02:00
13b3fde274
Fix stale activation record on failed jail activation
...
Record activation only after a successful jail activate request and add regression coverage to prevent stale last_activation state.
2026-04-17 14:53:57 +02:00
73cc212e28
Invert blocklist scheduler dependency to task callback
2026-04-15 21:31:08 +02:00
a5e95e2061
Replace __import__('datetime') antipattern in health_check task
2026-04-15 21:22:56 +02:00
56f03f39c7
Move history archive max timestamp query into repository
2026-04-15 21:18:44 +02:00
cdb0c3681e
Task 3: remove config_file_service facade, update direct imports and tests
2026-04-15 21:16:00 +02:00
0e22d1c425
Move config file exceptions into app.exceptions
...
Move ConfigDirError, ConfigFileNotFoundError, ConfigFileExistsError, ConfigFileWriteError, and ConfigFileNameError from raw_config_io_service into the shared domain exception module. Update router and tests to import the exceptions from app.exceptions.
2026-04-15 10:28:27 +02:00
328f3575e2
Move Fail2Ban exceptions into central app.exceptions module
2026-04-15 10:22:48 +02:00
a79f5339bc
Refactor fail2ban DB path lookup and simplify geo router response
2026-04-15 09:15:50 +02:00
56c511d905
Fix module-level asyncio locks in jail_service
...
Initialize jail_service locks lazily to avoid import-time event loop binding and add regression tests for lock creation.
2026-04-15 09:10:38 +02:00
a8f2d2d7b9
Refactor geo re-resolve endpoint into geo_service and add typed response
2026-04-15 08:56:37 +02:00
2451ec77b2
Refactor config file service facade wrappers and mark TASK-06 complete in Docs/Tasks.md
2026-04-15 08:25:12 +02:00
b70dc6fa7a
Refactor blocklist schedule management into service
2026-04-14 15:25:36 +02:00
58bb769a35
Refactor history sync into history_service and update docs/tests
2026-04-14 15:09:58 +02:00
86fa271c40
Remove FastAPI dependency from jail config service signatures
2026-04-14 15:01:05 +02:00
41f8c1f6cb
Remove task import from jail_config_service and mark TASK-03 done
2026-04-14 14:38:43 +02:00
2a7766d206
Wrap blocking mkdir() calls in run_blocking for async startup and setup
2026-04-14 13:54:47 +02:00
6b436dc354
Fix undefined names and config router imports / task status update
2026-04-14 13:53:39 +02:00
09c764cebc
Task 25: extend service/repository protocol coverage and wire DI aliases
2026-04-14 12:32:42 +02:00
b1fba79a2e
Remove unused asyncio import from log_service
...
Clean log_service.py by deleting the unused asyncio import and mark Task 24 completed in Docs/Tasks.md.
2026-04-14 12:19:35 +02:00
53cdd63b6a
Add no-op session cache when session cache is disabled
...
Use NoOpSessionCache in backend/app/main.py and dynamically switch cache implementation in backend/app/dependencies.py so disabled cache mode remains safe while get_session_cache always returns a valid object.
2026-04-14 12:14:50 +02:00
ec91c1c8b2
Use shared blocking executor in run_blocking
...
Wire DEFAULT_BLOCKING_EXECUTOR as the default executor in backend/app/utils/async_utils.py, preserving custom executors and marking Task 22 completed in Docs/Tasks.md.
2026-04-14 12:07:35 +02:00
fdede3e7dd
Offload ensure_jail_configs to a thread during startup
...
Use run_blocking for synchronous jail config file creation in backend/app/startup.py and mark Task 20 completed in Docs/Tasks.md.
2026-04-14 12:01:27 +02:00
5379cca238
Remove unused asyncio import from auth_service
2026-04-14 10:37:28 +02:00
0e5e08374f
Use shared SESSION_COOKIE_NAME in auth router tests
2026-04-14 10:33:32 +02:00