mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(api): 400 for exam-challenge route with no params (#62404)
This commit is contained in:
@@ -1304,6 +1304,16 @@ describe('/exam-environment/', () => {
|
|||||||
);
|
);
|
||||||
expect(res3.status).toBe(200);
|
expect(res3.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return 400 if neither challengeId or examId are provided', async () => {
|
||||||
|
const res = await superGet(`/exam-environment/exam-challenge`);
|
||||||
|
expect(res).toMatchObject({
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
code: 'FCC_ERR_EXAM_ENVIRONMENT'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1010,6 +1010,16 @@ export async function getExamChallenge(
|
|||||||
|
|
||||||
logger.info({ challengeId, examId });
|
logger.info({ challengeId, examId });
|
||||||
|
|
||||||
|
if (!challengeId && !examId) {
|
||||||
|
logger.warn('No challenge or exam id provided.');
|
||||||
|
void reply.code(400);
|
||||||
|
return reply.send(
|
||||||
|
ERRORS.FCC_ERR_EXAM_ENVIRONMENT(
|
||||||
|
'Must provide either a challengeId or examId.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const maybeData = await mapErr(
|
const maybeData = await mapErr(
|
||||||
this.prisma.examEnvironmentChallenge.findMany({
|
this.prisma.examEnvironmentChallenge.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
Reference in New Issue
Block a user