Repository navigation
Description
Summary
The secret-redaction tests each install their own regex set into a single process-global SECRETS_REGEX and then assert on the resulting detections. Run in parallel (or sequentially without teardown), one test overwrites another's regexes before its assertion runs, so the loser detects zero secrets instead of one and panics with left: 0, right: 1. Which member fails rotates run-to-run — the classic parallel-isolation signature — and all members pass in isolation. These currently report as failures on every contributor's full-suite PR gate.
Affected tests
Primary (app/src/terminal/model/grid/secrets_tests.rs):
terminal::model::grid::grid_handler::secrets::tests::test_secret_redacted_after_byte_processing(:34)terminal::model::grid::grid_handler::secrets::tests::test_secret_redacted_after_multiple_byte_processingterminal::model::grid::grid_handler::secrets::tests::test_secret_redaction_secret_remains_after_resize(:249)terminal::model::grid::grid_handler::secrets::tests::test_secret_redaction_unobfuscated_secret_remains_after_byte_processingterminal::model::grid::grid_handler::secrets::tests::test_bytes_processed_for_secrets_after_turning_redactionand the_on/_off_then_on/_on_then_offvariants (:270, :301, :327, :362)
Secondary consumer of the same global, observed failing under full-suite load:
ai::blocklist::block::secret_redaction::tests::test_detect_secrets_no_regexes_configured
Other modules that also write the same global (relevant to serialization scope): app/src/ai/blocklist/block/secret_redaction_tests.rs, app/src/ai/blocklist/action_model/execute/grep_tests.rs, app/src/server/telemetry/secret_redaction.rs.
Reproduction
Full suite — the secrets member(s) that fail vary between runs:
cargo test -p warp --lib
# run A: fails test_secret_redaction_secret_remains_after_resize
# run B: fails test_secret_redacted_after_byte_processing (+ ai::blocklist ... test_detect_secrets_no_regexes_configured)
# run C: no secrets failures
The module self-pollutes even alone (5 pass / 5 fail):
cargo test -p warp --lib terminal::model::grid::grid_handler::secrets
# => test result: FAILED. 5 passed; 5 failed
Every named test passes in isolation:
cargo test -p warp --lib -- --exact terminal::model::grid::grid_handler::secrets::tests::test_secret_redacted_after_byte_processing
# => ok. 1 passed
--test-threads=1 does not fully fix it — the tests still share the same global with no teardown, so ordering alone can still overwrite regexes between sequential tests.
Observed panic (identical across members):
thread '…::test_secret_redacted_after_byte_processing' panicked at app/src/terminal/model/grid/secrets_tests.rs:50:5:
assertion `left == right` failed
left: 0
right: 1
Root cause
There is exactly one process-global regex registry for secret detection:
// app/src/terminal/model/secrets.rs:54
pub static ref SECRETS_REGEX: Mutex<Arc<SecretsRegex>> = Mutex::new(
Arc::new(SecretsRegex {
regex: regex_automata::meta::Regex::new_many(&[] as &[&str])...,
...
})
);Every test configures its own regexes into this single global via set_user_and_enterprise_secret_regexes (secrets.rs:351), e.g.:
// app/src/terminal/model/grid/secrets_tests.rs:35
crate::terminal::model::secrets::set_user_and_enterprise_secret_regexes(
[&Regex::new("ABCD").expect("...")],
std::iter::empty(),
);
...
assert_eq!(grid_handler.secrets.len(), 1); // :50The detection path reads the same global:
// app/src/ai/blocklist/block/secret_redaction.rs:26
let secrets_regex: Arc<SecretsRegex> = { SECRETS_REGEX.lock().clone() };When two secret tests run concurrently (or sequentially without reset), test B's set_user_and_enterprise_secret_regexes(...) replaces test A's regexes — or resets toward a set that doesn't match A's input — before A's assert_eq!(secrets.len(), 1) runs. A then detects 0 secrets → left: 0, right: 1. Because the ordering that decides the loser varies, a different member fails each run, and sometimes none do.
Note on the _turning_redaction* family: those tests additionally call grid_handler.obfuscate_secrets(...) (e.g. secrets_tests.rs:291), but obfuscation mode is per-GridHandler local state, not the shared global. The regex registry is the sole cross-test culprit — the "redaction toggle" in the test name should not be read as implying a redaction-mode global; there isn't one.
Fix direction
Serialize the secret tests into one group and give the global proper per-test scoping:
- Mark the secret-redaction tests (across
grid/secrets_tests.rs,ai/blocklist/block/secret_redaction_tests.rs,ai/blocklist/action_model/execute/grep_tests.rs,server/telemetry/secret_redaction.rs) with a shared#[serial]group so they cannot interleave on the global. - Additionally, either save and restore
SECRETS_REGEXaround each test (snapshot theArcon entry, restore on drop via an RAII guard) or add a test-scoped override analogous to the feature-flagoverride_enabledpattern, so serialization is not the only line of defense.
Serialization alone reduces flakiness but leaves the tests coupled through the global; the save/restore (or scoped override) is what actually isolates them.
Related
Related: #13853 (warp_editor render::tests Once-poisoning — same class, different crate) and the sibling flake tickets filed alongside this one: #13972, #13974, #13975
Activity
warp-for-oss commentedon Jul 19, 2026
@fbartho
Here's what I found while triaging this issue:
Thanks for the detailed flake report. The current code supports this as an actionable shared test-state bug: multiple tests configure one process-global secret-regex registry and then assert against detection paths that read it.
Maintainer details
I concluded that secret-redaction tests appear to race through shared process-global secret regex state, causing nondeterministic failures in full or module-level test runs..
Initial triage
This looks like an actionable test-isolation bug in the terminal secret-redaction stack. The report's core symptom is well-supported: multiple tests configure process-global secret regex state and then assert against detection behavior that reads that same global.
Evidence
app/src/terminal/model/secrets.rsdefinesSECRETS_REGEXas a single process-globalMutex<Arc<SecretsRegex>>.set_user_and_enterprise_secret_regexesreplaces that global registry for future readers.app/src/terminal/model/grid/secrets_tests.rsconfigures different regex sets in individual tests without a per-test restore. Those tests then scan grid contents through code inapp/src/terminal/model/grid/secrets.rs, which clonesSECRETS_REGEXduring scanning.app/src/ai/blocklist/block/secret_redaction.rsalso clonesSECRETS_REGEXinfind_secrets_in_text_with_levels, so AI blocklist tests that expect empty or specific secret patterns can be affected by prior or concurrent tests.app/src/ai/blocklist/action_model/execute/grep_tests.rsalso writes the terminal secret regex global.Reproducibility
High. The issue includes concrete cargo commands, affected test names, and an assertion failure, and the shared global state in the current code explains both the nondeterminism and the all-tests-pass-in-isolation behavior. I did not need additional reporter input to classify this.
Likely fix direction
Add explicit test isolation for secret-regex global state. A robust fix would provide a test helper/guard that snapshots and restores
SECRETS_REGEXaround each test that mutates it, and serialize the tests that mutate/read this process-global state so they cannot interleave while the override is active.One scope note: the report also mentions
app/src/server/telemetry/secret_redaction.rsas a writer of the same global, but current code shows that module uses its ownTELEMETRY_SECRETS_REGEXregistry rather thanSECRETS_REGEX. It may have analogous global-test-state considerations, but it is not evidence for this exact sharedSECRETS_REGEXrace.Duplicate search
I compared against all open non-PR issues and recently closed issues within the 7-day dedupe window. I found related secret-redaction feature/behavior issues and sibling full-suite flake reports, but no likely duplicate for this specific
SECRETS_REGEXtest race.This is my automated analysis and may be incorrect. A maintainer will verify the details.
Powered by Oz
fbartho commentedon Jul 21, 2026
I proactively attempted an implementation based on the ticket as it's currently written: #14040.
If the ticket changes, I'm happy to update the PR to match a maintainer's guidance, just let me know!
fbartho commentedon Jul 28, 2026
Just nudging @oss-maintainers that this is still a real flake, and that I have a proposed fix here: #14040
Billing & Usage: split Team vs Workspace bonus-credit balance cards (#…