fix(session/database): auto-populate update_time for app/user state rows (#1177) - #1374
Closed
rootkiller6788 wants to merge 1 commit into
Closed
fix(session/database): auto-populate update_time for app/user state rows (#1177)#1374rootkiller6788 wants to merge 1 commit into
rootkiller6788 wants to merge 1 commit into
Conversation
rootkiller6788
marked this pull request as ready for review
August 23, 2026 08:22
Contributor
|
Thanks for the fix. It's solved by #1204. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #1177 — persisting app- or user-scoped state via
session/databasefails on MySQL with default strict mode:storageAppState/storageUserStatedeclareUpdateTimewithout any auto-update tag, and neither write path (Create,AppendEvent) assigns it, so GORM writes Go's zerotime.Timeexplicitly. MySQL'sNO_ZERO_DATE/STRICT_TRANS_TABLESrejects that value. SQLite, PostgreSQL and Spanner happen to accept it, which is why the bug only shows up on MySQL.Fix
Tag both state models with
autoUpdateTime(mirroring adk-python, whoseStorageAppState.update_timeusesdefault=func.now(), onupdate=func.now()):GORM then fills the column with the current time on both INSERT (new app/user row) and UPDATE (state delta on an existing row), covering every save path instead of just the two call sites.
precision:6is preserved, so the DDL is unchanged (datetime(6)).Testing
TestDatabaseService_StateTablesPopulateUpdateTimeverifiesupdate_timeis populated afterCreate(app + user state) and refreshed afterAppendEventwith a state delta. Confirmed it fails before the fix (zeroupdate_time) and passes after.go test ./session/database/...— all green.go test ./session/...—session,session/database,session/sessiontestsuitegreen;session/vertexaiis not runnable in this environment (requires live gRPC/Vertex AI network access).go build -mod=readonly work— passes.go mod tidy -diff— no changes.A note on
-race: the race detector fails to start in this Windows sandbox (exit status 0xc0000139, missing runtime entry point), so-raceruns are not available here; the change is limited to GORM struct tags and a test, with no new concurrency.