stage #4522: fix /api/profiles UnboundLocalError 500 (regression from v0.51.528) + v0.51.530 CHANGELOG

This commit is contained in:
nesquena-hermes committed 2026-06-20 03:18:33 +00:00
1 parent 897d3832dd
commit 51e2fce823
3 files changed
+39 -1

No files matched your search

+6
View File
@@ -3,6 +3,12 @@
## [Unreleased]
## [v0.51.530] — 2026-06-20 — Release SO (fix /api/profiles 500)
### Fixed
- **`GET /api/profiles` no longer returns a 500 (UnboundLocalError).** A later branch in the request handler imports `get_active_profile_name` as a function-local, which made the name local across the whole handler; the `/api/profiles` branch referenced it before that import ran, so every call to the profiles list endpoint raised `UnboundLocalError`. The branch now imports the name it uses directly. Regression introduced in v0.51.528 and surfaced once the redundant local import was removed there; this restores the profiles list/dropdown. Thanks @TomBanksAU.
## [v0.51.529] — 2026-06-20 — Release SN (per-response jump button matches the session jump pill)
### Fixed
+4 -1
View File
@@ -8595,7 +8595,10 @@ def handle_get(handler, parsed) -> bool:
# ── Profile API (GET) ──
if parsed.path == "/api/profiles":
from api.profiles import list_profiles_api
from api.profiles import (
get_active_profile_name,
list_profiles_api,
)
return j(
handler,
+29
View File
@@ -0,0 +1,29 @@
from types import SimpleNamespace
from urllib.parse import urlparse
def test_profiles_route_returns_active_profile(monkeypatch):
import api.profiles as profiles
import api.routes as routes
expected_profiles = [{"name": "default", "is_default": True}]
monkeypatch.setattr(profiles, "list_profiles_api", lambda: expected_profiles)
monkeypatch.setattr(profiles, "get_active_profile_name", lambda: "default")
monkeypatch.setattr(routes, "_is_isolated_profile_mode", lambda: False)
monkeypatch.setattr(
routes,
"j",
lambda _handler, payload, status=200: {"status": status, "payload": payload},
)
response = routes.handle_get(SimpleNamespace(), urlparse("/api/profiles"))
assert response == {
"status": 200,
"payload": {
"profiles": expected_profiles,
"active": "default",
"single_profile_mode": False,
},
}