Make app bootstrap and health result schemas strict

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 12:44:49 +00:00
1 parent 5d13d3cd61
commit 8afca7081f
2 files changed
+33 -2

No files matched your search

+31
View File
@@ -63,6 +63,25 @@ describe("appBootstrapResultSchema", () => {
}),
).toThrow();
});
it("rejects unexpected bootstrap payload properties", () => {
expect(() =>
appBootstrapResultSchema.parse({
launchCwd: "/workspace",
projectName: "workspace",
provider: "codex",
model: "gpt-5-codex",
session: {
sessionId: "sess-1",
provider: "codex",
status: "ready",
createdAt: "2026-02-01T00:00:00.000Z",
updatedAt: "2026-02-01T00:00:00.000Z",
},
unexpected: true,
}),
).toThrow();
});
});
describe("appHealthResultSchema", () => {
@@ -98,6 +117,18 @@ describe("appHealthResultSchema", () => {
}),
).toThrow();
});
it("rejects unexpected health payload properties", () => {
expect(() =>
appHealthResultSchema.parse({
status: "ok",
launchCwd: "/workspace",
sessionCount: 1,
activeClientConnected: true,
unexpected: true,
}),
).toThrow();
});
});
describe("dialogsPickFolderResultSchema", () => {
+2 -2
View File
@@ -28,14 +28,14 @@ export const appBootstrapResultSchema = z.object({
model: z.string().min(1),
session: providerSessionSchema,
bootstrapError: z.string().min(1).optional(),
});
}).strict();
export const appHealthResultSchema = z.object({
status: z.literal("ok"),
launchCwd: z.string().min(1),
sessionCount: z.number().int().min(0),
activeClientConnected: z.boolean(),
});
}).strict();
export const dialogsPickFolderResultSchema = z.string().nullable();
export type AppBootstrapResult = z.infer<typeof appBootstrapResultSchema>;