From 666537cdee215f84c9dc1fec55e5500a8e6a15d7 Mon Sep 17 00:00:00 2001 From: siddseethepalli Date: Wed, 15 Apr 2026 03:38:07 +0000 Subject: [PATCH] fix(tests): isolate encrypted store per test file to prevent parallel races MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parallel test processes were all reading/writing `~/.vellum/protected/keys.enc`, causing six email CLI tests to fail intermittently in CI. The "missing platform credentials returns error" tests delete the API key and expect the credential check to fire, but a parallel test file that sets the key between the delete and the command's fetch leaves the key in place — the command then attempts an unmocked HTTP call and fails with "No mock matched". Override the store path in test-preload.ts so each test file's bun process gets its own keys.enc under the per-file temp workspace. --- assistant/src/__tests__/test-preload.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assistant/src/__tests__/test-preload.ts b/assistant/src/__tests__/test-preload.ts index 0f15afe1070..6ae7a76d900 100644 --- a/assistant/src/__tests__/test-preload.ts +++ b/assistant/src/__tests__/test-preload.ts @@ -17,6 +17,7 @@ import { join } from "node:path"; import { afterAll } from "bun:test"; import { resetDb } from "../memory/db-connection.js"; +import { _setStorePath } from "../security/encrypted-store.js"; const testDir = realpathSync( mkdtempSync(join(tmpdir(), "vellum-test-workspace-")), @@ -25,6 +26,11 @@ process.env.VELLUM_WORKSPACE_DIR = testDir; process.env.VELLUM_PLATFORM_URL = "https://test-platform.vellum.ai"; process.exitCode = 0; +// Isolate the encrypted credential store per test file. Without this, +// parallel test processes all read/write the same ~/.vellum/protected/keys.enc, +// causing races when one file deletes a key while another sets it. +_setStorePath(join(testDir, "keys.enc")); + // Force-close any DB connection inherited from the parent process (e.g. when // the test runner is spawned by the running assistant via a pre-push hook). // Without this, the db singleton in db-connection.ts may still point at the