Repository navigation
Description
cli::tests::dictionary_rows_match_server_canonical_forms_and_hashes fails about 1 run in 3 locally (cargo test -p er-cli --lib dictionary_rows): CSV error: record 1 (line: 2, byte: 4): found record with 1 fields, but the previous record has 2 fields.
with_dictionary (rust/crates/er-cli/src/cli.rs ~585) names its temp file er-cli-dictionary-{pid}-{SystemTime nanos}.csv. macOS SystemTime has microsecond resolution, so two tests running in parallel in one process can pick the same path and read each other's CSV. CI runs on Linux, where the nanosecond clock makes a collision rarer, but the race is the same.
Fix: add a process-wide AtomicU64 counter to the name, or use tempfile. Found while running make check for #1202, which does not touch er-cli.
Product context (2026-11-26)
Why this matters for the API product: Indirect, it's about merge-gate trust. These tests guard the lexicon and ignore-words dictionaries that matching config loads. A flaky local make check teaches people to rerun until green.
Current state: The bug is unchanged on main.
with_dictionaryis atrust/crates/er-cli/src/cli.rs:582-594. It still names the fileer-cli-dictionary-{pid}-{SystemTime nanos}.csvin the shared temp dir.- The likely collision partner is
malformed_dictionary_rows_name_the_file_and_row(cli.rs:620), which runs in parallel in the same process. Its"a,b\nonly-one\n"input produces exactly the reported "found record with 1 fields" error. - er-cli has no
tempfiledev-dependency.er-serverander-pg-tlsalready usetempfile3. - The last change to the file was fix(rust): resolve crate audit cleanup tickets #957-#983 #1003 (0e731ca), which didn't touch this helper.
Definition of done:
- Each
with_dictionarycall gets a unique path: atempfile::NamedTempFile, or anAtomicU64counter in the name. cargo test -p er-cli --lib dictionarypasses 50 consecutive runs on macOS.
Dependencies / sequencing: None.
Size: ~0.05 engineer-weeks.
Activity
fix(er-cli): give each dictionary test file a unique temp path (#1203) (