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 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-08-21 06:21:33 -04:00
parent f8879d13c4
commit e89f03b316
No known key found for this signature in database

View file

@ -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::<RunId>().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]