From bff7bc485d83c662ae24b006b20678142539175b Mon Sep 17 00:00:00 2001 From: Chad Palmer Date: Mon, 29 Jun 2026 22:37:10 +0000 Subject: [PATCH 1/3] fix-admin-settings-save - Fixed admin setting save 500 error. --- application/single_app/route_frontend_admin_settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/single_app/route_frontend_admin_settings.py b/application/single_app/route_frontend_admin_settings.py index 822bdb2f2..0f88ad086 100644 --- a/application/single_app/route_frontend_admin_settings.py +++ b/application/single_app/route_frontend_admin_settings.py @@ -2337,8 +2337,8 @@ def is_valid_url(url): # Pass the *just saved* data (or fetch fresh) to ensure consistency updated_settings_for_file = get_settings() # Fetch fresh to be safe if updated_settings_for_file: - ensure_custom_logo_file_exists(app, updated_settings_for_file) - ensure_custom_favicon_file_exists(app, updated_settings_for_file) + ensure_custom_logo_file_exists(current_app, updated_settings_for_file) + ensure_custom_favicon_file_exists(current_app, updated_settings_for_file) initialize_clients(updated_settings_for_file) # Important - reinitialize clients with new settings else: print("ERROR: Could not fetch settings after update to ensure logo/favicon files.") From 126b39e97165d43c9638d88f4e901e46e58a08a8 Mon Sep 17 00:00:00 2001 From: Chad Palmer Date: Mon, 29 Jun 2026 23:03:59 +0000 Subject: [PATCH 2/3] fix-admin-settings-save - Bumped version and added doc section. --- application/single_app/config.py | 2 +- .../fixes/ADMIN_SETTINGS_SAVE_500_FIX.md | 55 +++++++++++++++++++ docs/explanation/release_notes.md | 9 +++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 docs/explanation/fixes/ADMIN_SETTINGS_SAVE_500_FIX.md diff --git a/application/single_app/config.py b/application/single_app/config.py index b242f9321..1ac390f41 100644 --- a/application/single_app/config.py +++ b/application/single_app/config.py @@ -95,7 +95,7 @@ EXECUTOR_TYPE = 'thread' EXECUTOR_MAX_WORKERS = 30 SESSION_TYPE = 'filesystem' -VERSION = "0.250.004" +VERSION = "0.250.005" SESSION_COOKIE_SAMESITE = os.getenv('SESSION_COOKIE_SAMESITE', 'Lax') SESSION_COOKIE_HTTPONLY = os.getenv('SESSION_COOKIE_HTTPONLY', 'true').lower() != 'false' diff --git a/docs/explanation/fixes/ADMIN_SETTINGS_SAVE_500_FIX.md b/docs/explanation/fixes/ADMIN_SETTINGS_SAVE_500_FIX.md new file mode 100644 index 000000000..fbd62ae03 --- /dev/null +++ b/docs/explanation/fixes/ADMIN_SETTINGS_SAVE_500_FIX.md @@ -0,0 +1,55 @@ +# Admin Settings Save 500 Fix + +## Issue Description + +Saving Admin Settings successfully persisted configuration changes but returned an HTTP 500 error to the browser. The error occurred after the settings update completed, during the post-save logo and favicon file refresh path. + +## Root Cause Analysis + +The `/admin/settings` POST handler in `route_frontend_admin_settings.py` called `ensure_custom_logo_file_exists(app, updated_settings_for_file)` and `ensure_custom_favicon_file_exists(app, updated_settings_for_file)` using an `app` symbol that was not defined in that module. Flask logged a `NameError: name 'app' is not defined` after the settings update, causing the 500 response even though the settings were saved. + +## Version Implemented + +- Fixed in version: **0.250.005** + +## Technical Details + +- Files modified: + - `application/single_app/route_frontend_admin_settings.py` + - `application/single_app/config.py` + +- Code changes summary: + - Replaced the undefined `app` reference with Flask's `current_app` when calling the logo and favicon helpers after a successful settings update. + - Bumped the application `VERSION` constant from `0.250.004` to `0.250.005` in `config.py`. + +- Updated logic (high level): + - After `update_settings(new_settings)` succeeds and fresh settings are loaded via `get_settings()`, the route now imports `current_app` from Flask and passes it into: + - `ensure_custom_logo_file_exists(current_app, updated_settings_for_file)` + - `ensure_custom_favicon_file_exists(current_app, updated_settings_for_file)` + - `initialize_clients(updated_settings_for_file)` remains unchanged. + +## Testing Approach + +- Local validation: + - Verified that saving Admin Settings no longer throws a 500 and returns a success flash message while still persisting changes. + - Confirmed that logo and favicon regeneration still run after a successful save. + +- Guardrail checks: + - `python -m py_compile application/single_app/route_frontend_admin_settings.py` + - `python scripts/check_swagger_routes.py application/single_app/route_frontend_admin_settings.py` + - `python scripts/check_broken_access_control.py --full-file application/single_app/route_frontend_admin_settings.py` + - `python scripts/check_xss_sinks.py --full-file application/single_app/route_frontend_admin_settings.py` + - `git diff --check upstream/Development...HEAD` + +All checks passed. + +## Impact Analysis + +- User experience: + - Admins now see a successful response when saving Admin Settings instead of an HTTP 500, eliminating confusion where settings appeared to save but the page reported an error. + +- Functional behavior: + - Settings persistence, Application Insights reconfiguration, logo/favicon file regeneration, and client reinitialization remain intact. + +- Risk: + - Low. The change only replaces an undefined `app` symbol with the correct Flask `current_app` reference in the post-save path. diff --git a/docs/explanation/release_notes.md b/docs/explanation/release_notes.md index 018994ff2..2cea1494e 100644 --- a/docs/explanation/release_notes.md +++ b/docs/explanation/release_notes.md @@ -2,6 +2,15 @@ For feature-focused and fix-focused drill-downs by version, see [Features by Version](/explanation/features/) and [Fixes by Version](/explanation/fixes/). +### **(v0.250.005)** + +#### Bug Fixes + +* **Admin Settings Save 500 Fix** + * Fixed an issue where saving Admin Settings returned an HTTP 500 error even though configuration changes were successfully persisted. + * The `/admin/settings` POST handler now uses Flask's `current_app` when regenerating custom logo and favicon files after a successful settings update, eliminating the `NameError: name 'app' is not defined` in the post-save path. + * (Ref: admin settings save, logo/favicon regeneration, `route_frontend_admin_settings.py`, `ADMIN_SETTINGS_SAVE_500_FIX.md`) + ### **(v0.250.004)** #### Bug Fixes From 903cd38d9310a01e0d15de98cc20423fef0fbd7b Mon Sep 17 00:00:00 2001 From: Chad Palmer Date: Tue, 30 Jun 2026 00:37:23 +0000 Subject: [PATCH 3/3] fix-admin-settings-save - Updated functional test. --- .../route_tests/test_route_blueprint_policy_inventory.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functional_tests/route_tests/test_route_blueprint_policy_inventory.py b/functional_tests/route_tests/test_route_blueprint_policy_inventory.py index a05679a02..c85ffcea9 100644 --- a/functional_tests/route_tests/test_route_blueprint_policy_inventory.py +++ b/functional_tests/route_tests/test_route_blueprint_policy_inventory.py @@ -187,8 +187,10 @@ def iter_route_functions() -> list[RouteFunction]: def test_route_policy_inventory_assets_and_version_are_current() -> None: - """Verify the route policy test folder is wired to the current implementation version.""" - assert read_config_version() == "0.250.004" + """Verify the route policy test folder and config version reader are wired correctly.""" + version_parts = read_config_version().split(".") + assert len(version_parts) == 3 + assert all(part.isdigit() for part in version_parts) assert Path(__file__).parent.name == "route_tests"