Skip to content

Commit 8335f35

Browse files
hiroakisseanzhougoogle
authored andcommitted
fix: Change error_message column type to TEXT in DatabaseSessionService
Merge #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 <seanzhougoogle@google.com> COPYBARA_INTEGRATE_REVIEW=#3917 from hiroakis:main 1474fd5 PiperOrigin-RevId: 844845692
1 parent e515e0f commit 8335f35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/google/adk/sessions/database_session_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class StorageEvent(Base):
269269
error_code: Mapped[str] = mapped_column(
270270
String(DEFAULT_MAX_VARCHAR_LENGTH), nullable=True
271271
)
272-
error_message: Mapped[str] = mapped_column(String(1024), nullable=True)
272+
error_message: Mapped[str] = mapped_column(Text, nullable=True)
273273
interrupted: Mapped[bool] = mapped_column(Boolean, nullable=True)
274274
input_transcription: Mapped[dict[str, Any]] = mapped_column(
275275
DynamicJSON, nullable=True

0 commit comments

Comments
 (0)