From 8335f35015c7d4349bc4ac47dedbe99663b78e62 Mon Sep 17 00:00:00 2001 From: Hiroaki Sano Date: Mon, 15 Dec 2025 11:08:54 -0800 Subject: [PATCH] fix: Change error_message column type to TEXT in DatabaseSessionService Merge https://github.com/google/adk-python/pull/3917 To migrate from existing DB : ALTER TABLE events ALTER COLUMN error_message TYPE TEXT; -- PostgreSQL ALTER TABLE events MODIFY error_message TEXT; -- MySQL SQLite: Doesn't enforce VARCHAR length limits anyway. No impact. ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** n/a **2. Or, if no issue exists, describe the change:** **Problem:** When storing events with error messages longer than 1024 characters using `DatabaseSessionService`, PostgreSQL raises: ``` ERROR: value too long for type character varying(1024) ``` The `error_message` column in `StorageEvent` is defined as `String(1024)`, which maps to `VARCHAR(1024)`. Error messages can exceed 1024 characters. **Solution:** Change the column type from `String(1024)` to `Text` to allow unlimited length error messages. ### Testing Plan **Unit Tests:** - [x] I have added or updated unit tests for my change. - [x] All unit tests pass locally. $ pytest ./tests/unittests/sessions/ -v ======================= 75 passed, 3 warnings in 26.92s ======================== **Manual End-to-End (E2E) Tests:** - Verified that events with long error messages (>1024 chars) can be stored in PostgreSQL - Verified backward compatibility with existing databases ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. - [x] I have manually tested my changes end-to-end. - [x] Any dependent changes have been merged and published in downstream modules. ### Additional context This is a minimal change (1 line) that only affects the `error_message` column type definition. Co-authored-by: Xiang (Sean) Zhou COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3917 from hiroakis:main 1474fd552cdbd7206de383e5507fd8a733aecda1 PiperOrigin-RevId: 844845692 --- src/google/adk/sessions/database_session_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/adk/sessions/database_session_service.py b/src/google/adk/sessions/database_session_service.py index a3529182..047340c5 100644 --- a/src/google/adk/sessions/database_session_service.py +++ b/src/google/adk/sessions/database_session_service.py @@ -269,7 +269,7 @@ class StorageEvent(Base): error_code: Mapped[str] = mapped_column( String(DEFAULT_MAX_VARCHAR_LENGTH), nullable=True ) - error_message: Mapped[str] = mapped_column(String(1024), nullable=True) + error_message: Mapped[str] = mapped_column(Text, nullable=True) interrupted: Mapped[bool] = mapped_column(Boolean, nullable=True) input_transcription: Mapped[dict[str, Any]] = mapped_column( DynamicJSON, nullable=True