Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions application/single_app/route_frontend_admin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
55 changes: 55 additions & 0 deletions docs/explanation/fixes/ADMIN_SETTINGS_SAVE_500_FIX.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions docs/explanation/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
Loading