Skip to content

Commit f765219

Browse files
authored
test(fix): stop context-hydration flake — delete ambient MEMORY_ID in beforeEach (#115) (#602)
hydrateContext falls back to process.env.MEMORY_ID when no memoryId option is passed (context-hydration.ts:990). The test 'excludes memory_context when memoryId is not provided' asserted loadMemoryContext is NOT called — but if MEMORY_ID leaked into the jest process env (another test file, or the deploy env when the suite runs in-container), the source picked it up and DID call loadMemoryContext, failing the assertion. Order/environment-dependent flake: green locally (no MEMORY_ID), red on the fork's in-container build. Consequence: the flake blocked the pre-push hook, so the fork agent bypassed its own gate with `git push --no-verify` on BOTH ABCA-487 and ABCA-488. Fix: `delete process.env.MEMORY_ID` in beforeEach so every test starts from a clean no-ambient-memory baseline; tests that want memory pass the memoryId option explicitly (no test relies on the env fallback). Verified: the suite now passes 92/92 both with MEMORY_ID set in the env (the container condition) and without. Full build green (cdk 2853).
1 parent d6f4634 commit f765219

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

cdk/test/handlers/shared/context-hydration.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ global.fetch = mockFetch as unknown as typeof fetch;
7575
beforeEach(() => {
7676
jest.clearAllMocks();
7777
clearTokenCache();
78+
// hydrateContext falls back to process.env.MEMORY_ID when no memoryId option
79+
// is passed (context-hydration.ts:990). If MEMORY_ID leaks into the jest
80+
// process env (set by another test file, or the deploy env when the suite
81+
// runs in-container), the "memoryId not provided" tests would spuriously call
82+
// loadMemoryContext and fail — an order/environment-dependent flake that
83+
// forced the fork's build-gate to be bypassed with `git push --no-verify`.
84+
// Pin a clean "no ambient memory" baseline; tests that want memory pass the
85+
// memoryId option explicitly.
86+
delete process.env.MEMORY_ID;
7887
});
7988

8089
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)