Skip to content

Commit 9a2d46f

Browse files
committed
fix: use sqlx chrono decode for thread timestamps instead of manual parsing
Use sqlx's native DateTime<Utc> decoding for thread timestamp columns instead of fetching as String and manually parsing. This was missed when the baxen/goose2 branch was merged into main via PR #8516. The manual parsing silently falls back to Utc::now() on parse failure, which could produce incorrect timestamps. Letting sqlx decode directly is both more correct and simpler. Signed-off-by: Matt Toohey <contact@matttoohey.com>
1 parent dc052f4 commit 9a2d46f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

crates/goose/src/session/thread_manager.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ type ThreadRow = (
5454
String,
5555
bool,
5656
Option<String>,
57-
String,
58-
String,
59-
Option<String>,
57+
DateTime<Utc>,
58+
DateTime<Utc>,
59+
Option<DateTime<Utc>>,
6060
String,
6161
Option<String>,
6262
i64,
@@ -70,21 +70,21 @@ fn thread_from_row(
7070
working_dir,
7171
created_at,
7272
updated_at,
73-
archived_at_str,
73+
archived_at,
7474
metadata_json,
7575
current_session_id,
7676
message_count,
7777
): ThreadRow,
7878
) -> Result<Thread> {
7979
let metadata: ThreadMetadata = serde_json::from_str(&metadata_json).unwrap_or_default();
80-
let archived_at = archived_at_str.as_deref().and_then(|s| s.parse().ok());
80+
8181
Ok(Thread {
8282
id,
8383
name,
8484
user_set_name,
8585
working_dir,
86-
created_at: created_at.parse().unwrap_or_else(|_| Utc::now()),
87-
updated_at: updated_at.parse().unwrap_or_else(|_| Utc::now()),
86+
created_at,
87+
updated_at,
8888
archived_at,
8989
metadata,
9090
current_session_id,

0 commit comments

Comments
 (0)