From e89f03b31675492c770365fe432467c01b4d19bd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 21 Aug 2026 06:21:33 -0400 Subject: [PATCH] Fix flaky run id vs variable timestamp assertion RunId is a ULID, so its embedded timestamp is truncated to whole milliseconds, while Variable.updated_at comes from Utc::now() with sub-millisecond precision. When the variable write and the run creation landed in the same millisecond, the run id compared as earlier and the assertion failed. Truncate the variable timestamp to milliseconds so both sides use the same precision. Co-Authored-By: Claude Fable 5 --- lib/apps/fabro-server/src/server/tests.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/apps/fabro-server/src/server/tests.rs b/lib/apps/fabro-server/src/server/tests.rs index b63923e79..dc656c32e 100644 --- a/lib/apps/fabro-server/src/server/tests.rs +++ b/lib/apps/fabro-server/src/server/tests.rs @@ -10,7 +10,7 @@ use std::sync::{Arc as StdArc, Mutex as StdMutex}; use async_zip::base::read::mem::ZipFileReader; use axum::body::Body; use axum::http::{Method, Request, header}; -use chrono::{Duration as ChronoDuration, Utc}; +use chrono::{Duration as ChronoDuration, SubsecRound as _, Utc}; use fabro_automation::{AutomationId, AutomationTarget}; use fabro_config::bind::Bind; use fabro_config::{ @@ -4069,7 +4069,9 @@ async fn create_run_from_manifest_resolves_generated_id_after_variable_snapshot( let body = response_json!(response, StatusCode::CREATED).await; let run_id = body["id"].as_str().unwrap().parse::().unwrap(); - assert!(run_id.created_at() >= variable.updated_at); + // RunId is a ULID whose timestamp only has millisecond precision, so + // truncate the variable timestamp to milliseconds before comparing. + assert!(run_id.created_at() >= variable.updated_at.trunc_subsecs(3)); } #[tokio::test]