Commit 8451dc0
committed
fix(sessions): truncate error_message in v0 StorageEvent to guard against VARCHAR(255) overflow
Databases created with earlier ADK versions retain error_message as
VARCHAR(255) because create_all() is additive-only and never ALTERs
existing columns. When a model returns a MALFORMED_FUNCTION_CALL error
with a large JSON payload, the unbounded error_message silently exceeds
that limit and raises StringDataRightTruncationError, terminating the
SSE stream with no fallback.
The fix adds a write-path guard in StorageEvent.from_event(): if the
message exceeds 255 characters it is clipped to 241 chars and suffixed
with "...[truncated]", keeping the total within the legacy column width.
Messages within the limit are passed through unchanged. The v1 schema is
unaffected (error_message is stored inside the event_data JSONB column).
The permanent fix remains running:
ALTER TABLE events ALTER COLUMN error_message TYPE TEXT;
or migrating to the v1 schema via `adk migrate session`.
Fixes #49931 parent f973673 commit 8451dc0
File tree
2 files changed
+54
-1
lines changed- src/google/adk/sessions/schemas
- tests/unittests/sessions
2 files changed
+54
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| |||
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
301 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
302 | 317 | | |
303 | 318 | | |
304 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments