Skip to content

Commit 4541bb4

Browse files
committed
fix: relax system info schema
1 parent 0f94306 commit 4541bb4

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎src/routes/v1/telemetry.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ telemetry.post(
2929
limit: 10,
3030
keyGenerator: (c) => c.get("clientIp"),
3131
}),
32-
zValidator("json", systemInfoSchema),
32+
zValidator("json", systemInfoSchema, (result, c) => {
33+
if ("error" in result && result.error) {
34+
const flat = result.error.flatten();
35+
console.warn("[telemetry] validation error:", JSON.stringify(flat));
36+
return c.json({ error: "Validation failed", details: flat }, 400);
37+
}
38+
}),
3339
async (c) => {
3440
const ua = c.req.header("User-Agent") || "";
3541
if (!ua.toLowerCase().startsWith("vicinae")) {

‎src/schemas/telemetry.ts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ export const forgetSchema = z.object({
1414

1515
export const systemInfoSchema = z.object({
1616
userId: z.string().min(1).max(256),
17-
desktops: z.array(z.string().min(1).max(64)).min(1).max(10),
18-
vicinaeVersion: z.string().regex(/^v\d+\.\d+\.\d+$/),
17+
desktops: z.array(z.string().min(1).max(64)).max(10),
18+
vicinaeVersion: z.string().min(1).max(64),
1919
displayProtocol: z.string().min(1).max(32),
2020
architecture: z.string().min(1).max(32),
2121
operatingSystem: z.string().min(1).max(32),
2222
buildProvenance: z.string().min(1).max(64),
23-
locale: z.string().regex(/^[a-z]{2}(_[A-Z]{2})?$/),
24-
screens: z.array(screenSchema).min(1).max(16),
25-
chassisType: z.enum(["laptop", "desktop", "other"]),
23+
locale: z.string().min(1).max(32),
24+
screens: z.array(screenSchema).max(16),
25+
chassisType: z.string().min(1).max(32),
2626
kernelVersion: z.string().min(1).max(128),
27-
productId: z.string().min(1).max(128),
28-
productVersion: z.string().min(1).max(128),
29-
qtVersion: z
30-
.string()
31-
.regex(/^\d+\.\d+\.\d+$/)
32-
.optional(),
27+
productId: z.string().max(128),
28+
productVersion: z.string().max(128),
29+
qtVersion: z.string().max(64).optional(),
3330
});
3431

3532
export type SystemInfoPayload = z.infer<typeof systemInfoSchema>;

0 commit comments

Comments
 (0)