Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Validate getImportStatus.ts

Edward Cui1ee63b9592a3
diff --git a/server/src/api/import/getImportStatus.ts b/server/src/api/import/getImportStatus.ts
index 9c7e764f8..dc468cdfc 100644
--- a/server/src/api/import/getImportStatus.ts
+++ b/server/src/api/import/getImportStatus.ts
@@ -23,8 +23,20 @@ export async function getImportStatus(
reply: FastifyReply,
) {
try {
- const { organization, site } = request.params;
- const { importId } = request.body;
+ const parsed = getImportStatusRequestSchema.safeParse({
+ params: request.params,
+ body: request.body,
+ });
+
+ if (!parsed.success) {
+ return reply.status(400).send({
+ error: "Validation failed",
+ details: parsed.error.flatten(),
+ });
+ }
+
+ const { organization, site } = parsed.data.params;
+ const { importId } = parsed.data.body;
const userHasAccess = await getUserHasAccessToSite(request, site);
if (!userHasAccess) {