Skip to content

Commit 3c223af

Browse files
authored
fix(cloud): honor selected sandbox image
Skip prewarmed sandbox reuse when a cloud environment or custom image is selected, so the cold run provisions with the requested configuration. Generated-By: PostHog Code Task-Id: 6b752fb1-4fa1-45e4-920a-38306e4b7cee
1 parent 9beff6e commit 3c223af

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

packages/core/src/task-detail/taskCreationSaga.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,48 @@ describe("TaskCreationSaga", () => {
687687
});
688688
});
689689

690+
it.each([
691+
{
692+
selection: "sandbox environment",
693+
input: { sandboxEnvironmentId: "environment-123" },
694+
expectedRunOptions: { sandboxEnvironmentId: "environment-123" },
695+
},
696+
{
697+
selection: "custom image",
698+
input: { customImageId: "image-123" },
699+
expectedRunOptions: { customImageId: "image-123" },
700+
},
701+
])(
702+
"starts a cold run for a selected $selection",
703+
async ({ input, expectedRunOptions }) => {
704+
const createdTask = createTask();
705+
const startedTask = createTask({ latest_run: createRun() });
706+
const createTaskMock = vi.fn().mockResolvedValue(createdTask);
707+
const createTaskRunMock = vi.fn().mockResolvedValue(createRun());
708+
const startTaskRunMock = vi.fn().mockResolvedValue(startedTask);
709+
const saga = makeSaga({
710+
createTask: createTaskMock,
711+
createTaskRun: createTaskRunMock,
712+
startTaskRun: startTaskRunMock,
713+
});
714+
715+
const result = await saga.run({
716+
content: "Ship the fix",
717+
repository: "posthog/posthog",
718+
workspaceMode: "cloud",
719+
branch: "main",
720+
...input,
721+
});
722+
723+
expect(result.success).toBe(true);
724+
expect(createTaskMock.mock.calls[0][0].branch).toBeUndefined();
725+
expect(createTaskRunMock).toHaveBeenCalledWith(
726+
"task-123",
727+
expect.objectContaining(expectedRunOptions),
728+
);
729+
},
730+
);
731+
690732
it("uses the selected user GitHub integration for cloud task creation", async () => {
691733
const createdTask = createTask({
692734
github_user_integration: "user-integration-123",

packages/core/src/task-detail/taskCreationSaga.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ export class TaskCreationSaga extends Saga<
685685
augmented,
686686
};
687687

688+
if (input.sandboxEnvironmentId || input.customImageId) {
689+
return { ...base, suppressWarmReuse: true };
690+
}
691+
688692
const lease = input.repository
689693
? this.deps.host.takeWarmTaskLease({
690694
repository: input.repository,

0 commit comments

Comments
 (0)