Skip to content

er-cli dictionary tests race on a shared temp path on macOS #1203

Done

Description

@athvin

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_dictionary is at rust/crates/er-cli/src/cli.rs:582-594. It still names the file er-cli-dictionary-{pid}-{SystemTime nanos}.csv in 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 tempfile dev-dependency. er-server and er-pg-tls already use tempfile 3.
  • 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:

  1. Each with_dictionary call gets a unique path: a tempfile::NamedTempFile, or an AtomicU64 counter in the name.
  2. cargo test -p er-cli --lib dictionary passes 50 consecutive runs on macOS.

Dependencies / sequencing: None.

Size: ~0.05 engineer-weeks.

Activity

  1. added
    followup
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    followup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions