fix: fail safe on missing workspace revisions
This commit is contained in:
@@ -15,7 +15,12 @@ test("createSession migrates legacy selections and POSTs browser preferences", a
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical",
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
}])),
|
||||
http.get("/api/workspaces/psd-clinical", () => HttpResponse.json({
|
||||
workspace: { llm_policy: { allowed: ["zai/glm-5.2"] } },
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
})),
|
||||
http.post("/api/sessions", async ({ request }) => {
|
||||
body = await request.json();
|
||||
return HttpResponse.json({ id: "s1" });
|
||||
@@ -30,6 +35,28 @@ test("createSession migrates legacy selections and POSTs browser preferences", a
|
||||
});
|
||||
});
|
||||
|
||||
test("createSession rejects a workspace summary that omits the canonical revision", async () => {
|
||||
localStorage.clear();
|
||||
let posted = false;
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({
|
||||
workspace: "psd-clinical", provider: "zai", model: "glm-5.2", thinking: "low",
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical",
|
||||
}])),
|
||||
http.post("/api/sessions", async () => {
|
||||
posted = true;
|
||||
return HttpResponse.json({ id: "s1" });
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(createSession({ question: "q" })).rejects.toMatchObject({
|
||||
message: "Could not load selected workspace policy. Please retry.",
|
||||
});
|
||||
expect(posted).toBe(false);
|
||||
});
|
||||
|
||||
test.each([202, 204])("prewarmRuntime accepts a body-less %s response", async (status) => {
|
||||
let called = false;
|
||||
server.use(
|
||||
|
||||
@@ -59,7 +59,11 @@ async function ensureWorkspaceSelectionPolicy(): Promise<WorkspacePreference> {
|
||||
throw new WorkspaceSelectionError(WORKSPACE_SUMMARY_ERROR);
|
||||
}
|
||||
if (workspacePreferences.load().workspaceId !== workspaceId) continue;
|
||||
if (workspace?.revision.state === "migration_required") {
|
||||
if (workspace && !workspace.revision) {
|
||||
workspacePolicyGate.reject(workspaceId);
|
||||
throw new WorkspaceSelectionError(WORKSPACE_POLICY_ERROR);
|
||||
}
|
||||
if (workspace?.revision?.state === "migration_required") {
|
||||
workspacePolicyGate.rejectSummary(workspaceId);
|
||||
throw new WorkspaceSelectionError(WORKSPACE_POLICY_ERROR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user