Commit fd810d1
routes: phone-context auto-creates session instead of 404
Real-world phone failure observed 2026-05-27:
POST /troubleshoot/phone-context HTTP/1.1" 404 Not Found
→ App shows "[http-not-found] Session not found"
Root causes the old 404 didn't handle gracefully:
1. User taps "Share my phone's context" BEFORE the first
/troubleshoot call — the app has generated a UUID for the
upcoming session and tries to prime it with phone state. The
server didn't know about the UUID yet.
2. Container restarted between sessions — the app's cached
session_id was valid before restart but the in-memory session
map is now empty. App shows scary "Session not found" instead
of just resuming.
Fix: when phone-context receives an unknown session_id, create the
session with that id instead of 404'ing. Idempotent prime-then-
troubleshoot — the next /troubleshoot with the same session_id
finds the session already there with phone_context attached.
The SessionManager.create(session_id=...) path already exists for
caller-supplied IDs in /troubleshoot; this just hooks it into
phone-context too.
Test updated: test_phone_context_unknown_session_returns_404 →
test_phone_context_unknown_session_auto_creates. Asserts the
session is created with the supplied id AND the phone_context is
attached. 244/244 tests still pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 9e1334c commit fd810d1
2 files changed
Lines changed: 48 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
178 | 197 | | |
| 198 | + | |
179 | 199 | | |
180 | 200 | | |
181 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
81 | 99 | | |
82 | 100 | | |
83 | 101 | | |
84 | 102 | | |
85 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
86 | 108 | | |
87 | 109 | | |
88 | 110 | | |
| |||
0 commit comments