Fix 500 errors if data is invalid (#2886)

pull/2885/head^2
Hariom Balhara 2022-05-26 14:08:10 +05:30 committed by GitHub
parent 7c3090bc23
commit 40c81ee405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -2294,6 +2294,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const session = await getSession({ req });
const typeParam = parseInt(asStringOrThrow(query.type));
if (Number.isNaN(typeParam)) {
return {
notFound: true,
};
}
if (!session?.user?.id) {
return {
redirect: {
@ -2406,7 +2412,11 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
},
});
if (!rawEventType) throw Error("Event type not found");
if (!rawEventType) {
return {
notFound: true,
};
}
const credentials = await prisma.credential.findMany({
where: {