New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Summary Length #12934
API Summary Length #12934
Conversation
Can't get tests to run on my machine so I'm not really sure why these are failing right now |
I would move the check to the model with a validator https://mongoosejs.com/docs/validation.html |
@@ -200,6 +205,7 @@ api.createChallenge = { | |||
const { user } = res.locals; | |||
|
|||
req.checkBody('group', apiError('groupIdRequired')).notEmpty(); | |||
if (req.body.challenge.summary && req.body.challenge.summary.length > MAX_SUMMARY_SIZE_FOR_CHALLENGES) throw new BadRequest(res.t('summaryTooLong')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if req.body.challenge
is not defined? Also this cose should go after the validation errors
@thewilloftheshadow the tests are failing because you're not checking for the existence of
|
Got it 👍🏻 |
To see the error you have to:
|
Ahh that's exactly what I needed! Tyty |
Closing this PR as abandoned. Worth peeking at for whoever picks this up next, though! |
Fixes #9244
Changes
API now rejects both new challenge and challenges update if summary is longer than maximum length
Adds tests for this new check
UUID: 2eb203f5-1b1e-4e5d-84a4-22f130a1090e