-
fix(sessions): unwrap FastAPI detail envelope in get_persona_state (v0.15.1)
released this
2026-05-27 19:11:16 -07:00 | 237 commits to main since this releaseLive smoke against personal:8081 during the v0.15.0 web-companion
verification surfaced that real Worldtree returns persona_state
errors in the FastAPI default envelope shape:{"detail": {"error_code": "auth_scope_denied", "message": "..."}}The v0.12.0
get_persona_stateparser only inspected the top-level
error_codekey. When the field was nested underdetail, the
typed exception (AuthScopeDenied / PersonaNotConfigured /
AgentNotAvailable) wasn't raised; the call fell through to
SessionApiFailed, which then surfaced through the web companion as
an opaque HTTP 500 on /api/agents/{id}/persona_state.The original test_sessions.py mocks used the flat-shape envelope, so
the bug was invisible in unit tests until the real-wire smoke.Fix: extract error_code from either
err.get("error_code")(flat)
ORerr.get("detail", {}).get("error_code")(FastAPI default).Patch per SemVer discipline — bug fix to v0.12.0 surface, no public
signature change, no new behavior. Callers that were getting the
wrong exception now get the right one; callers that were already
getting the right exception (flat-shape paths) are unchanged.Tests: 2 new regression cases in TestGetPersonaState — one each for
the detail-envelope shape of 403 auth_scope_denied and 404
persona_not_configured. Suite: 358 passing.Downloads