Skip to content

Commit 9add784

Browse files
committed
fix(cdk): make ecs-strategy top-of-file import hermetic vs ambient env
The inline-fallback / no-op tests in the top-of-file describe blocks assume the OPTIONAL vars ECS_PAYLOAD_BUCKET and ECS_PLANNING_TASK_DEFINITION_ARN are ABSENT when the module is first imported (it reads them as module-level constants). A dev shell has neither set, so the suite passed locally — but the REAL ECS agent container HAS ECS_PAYLOAD_BUCKET set (#502 payload bucket), so on ECS the const was truthy and the 'no bucket → inline fallback' + 'no-op' assertions failed: FAIL test/handlers/shared/strategies/ecs-strategy.test.ts ● startSession › sends RunTaskCommand with correct params ... ● deleteEcsPayload without ECS_PAYLOAD_BUCKET › no-ops ... This was the residual fork baseline-build exit-1: 2 failed / 3093 passed, only ever reproducible inside the ECS microVM. Surfaced by the live-streaming build log (the buffered summary had hidden it). Fix: delete both optional vars before the top-of-file import so it's hermetic regardless of the runner's environment; the #502/#299 describe blocks already set them via jest.isolateModules. (cherry picked from commit 7a2bde9) (cherry picked from commit 8267c29)
1 parent 26ec150 commit 9add784

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cdk/test/handlers/shared/strategies/ecs-strategy.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ process.env.ECS_TASK_DEFINITION_ARN = TASK_DEF_ARN;
2727
process.env.ECS_SUBNETS = 'subnet-aaa,subnet-bbb';
2828
process.env.ECS_SECURITY_GROUP = 'sg-12345';
2929
process.env.ECS_CONTAINER_NAME = 'AgentContainer';
30+
// The top-of-file import's inline-fallback / no-op tests assume these OPTIONAL
31+
// vars are ABSENT at load time. They are unset in a dev shell but the real ECS
32+
// agent container HAS ECS_PAYLOAD_BUCKET set (#502) — so leaving this to ambient
33+
// env made the build pass locally yet FAIL on ECS ("works local, dies on ECS").
34+
// The #502 / #299 describe blocks below set these via isolateModules; delete them
35+
// here so the top-of-file import is hermetic regardless of the runner's env.
36+
delete process.env.ECS_PAYLOAD_BUCKET;
37+
delete process.env.ECS_PLANNING_TASK_DEFINITION_ARN;
3038

3139
const mockSend = jest.fn();
3240
jest.mock('@aws-sdk/client-ecs', () => ({

0 commit comments

Comments
 (0)